GATE Computer ScienceVery hardGATE CS

A flow graph has nodes 1 to 10, entry node 1, and edges 1→2, 2→3, 3→4, 4→5, 5→3, 4→6, 6→7, 7→2, 7→8, 8→9, 9→8, 9→10, 6→10, 3→9. A back edge is an edge u→v in which v dominates u. What is the pair (number of back edges, number of nodes that belong to at least one natural loop)?

  1. A. (2, 8)
  2. B. (3, 6)
  3. C. (2, 6)
  4. D. (3, 8)

Correct answer: C. (2, 6)

The immediate dominators are 2:1, 3:2, 4:3, 5:4, 6:4, 7:6, 8:3, 9:3, 10:3. Only 5→3 and 7→2 go to a dominating node, giving loops {3,4,5} and {2,...,7}, whose union has 6 nodes. The cycle 8↔9 can be entered at both 8 and 9 (via 7→8 and 3→9), so neither dominates the other and it is not a natural loop (irreducible).

More Compiler Design questions

Exams that ask this topic