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
Which of the following is the correct flow graph (adjacency matrix of basic blocks B1–B7, row → column means an edge) for the TAC given in the passage?
Pick an option to check yourself, or open the answer below.
Show answer & explanation
Correct answer: A.
| 0 | 1 | 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 | 0 | 0 |
| 0 | 0 | 0 | 0 | 0 | 0 | 1 |
| 0 | 0 | 0 | 0 | 1 | 1 | 0 |
| 0 | 0 | 0 | 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Explanation
With B1 = 100–102, B2 = 103, B3 = 104, B4 = 105, B5 = 106, B6 = 107–110, B7 = 111–112, the edges are B1→B2; B2→B3, B4; B3→B7; B4→B5, B6; B5→B7; B6→B2; and B7 has no successor. Row-wise this is 0100000, 0011000, 0000001, 0000110, 0000001, 0100000, 0000000, which is option A.More Theory of Computation and Compilers questions
- Which of the following is TRUE about the Pumping Lemma for regular languages?
- Regarding code optimization (peephole optimization), choose the correct sequence A. Algebraic Simplification B. Use of machine idioms C. Re…
- Which of the following represents the language accepted by the Turing machine with the transition function (δ): δ(q0, a) = (q1, x, R) δ(q1,…
- Match List I with List IIList I List II A. Conflict Resolution I. Three-Address Code B. Common Subexpression II. Precedence C. Quadruples I…
- Match List I with List IIList I List II A. Type-0 Grammar I. Linear Grammar B. Type-1 Grammar II. GNF C. Type-2 Grammar III. x → y, |x| ≤ |…
- Which of the following CFG(s) is/are in Chomsky Normal Form? (All capital letters are variables & lower case letters are terminals) A. S →…