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)?
- A. (2, 8)
- B. (3, 6)
- C. (2, 6)
- 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
- For the flow graph with entry 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, which is the dominance…
- An expression is very busy at a point if, along every path from that point, it is evaluated before any of its operands is redefined…
- A heap holds objects A to J. Roots point to A and E. Pointers: A→B, B→C, B→D, C→B, D→F, E→F, E→I, G→H, H→G, H→J. The root pointer to A is…
- The live ranges (inclusive of both end points, in instruction numbers) of ten variables are [1,8], [2,5], [3,9], [4,6], [7,12], [10,14]…
- Linear-scan register allocation processes the same ten live ranges [1,8], [2,5], [3,9], [4,6], [7,12], [10,14], [11,13], [6,10], [9,15]…
- A syntax-directed translation scheme prints as it reduces: E → T + E { print('+') } | T; T → F T { print('') } | F; F → id {…