All mock tests are FREE till 31 December — register to save your progress

Directions (Q91–95): Consider the following Three Address Code sample for solving the questions:

100: t1 = y + 2
101: initial = x / t1
102: limit = 10
103: if i > j goto 105
104: goto 111
105: if num > b goto 107
106: goto 111
107: num = limit - 1
108: b = y + 2
109: i = i - num
110: goto 103
111: j = i - num
112: k = j + b

What blocks do Block 3 and Block 5 dominate in the flow graph for the TAC given in the passage? (Basic blocks: B1 = 100–102, B2 = 103, B3 = 104, B4 = 105, B5 = 106, B6 = 107–110, B7 = 111–112)

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: A. Block 3: 3; Block 5: 5

Explanation

Edges: B1→B2, B2→B3, B2→B4, B3→B7, B4→B5, B4→B6, B5→B7, B6→B2. B7 can be reached either through B3 or through B5, so neither B3 nor B5 dominates B7, and both have no other successors. Each dominates only itself.

More Theory of Computation and Compilers questions