GATE Computer ScienceModerateGATE CSE
How many basic blocks does this three-address code contain? 1: i = 0; 2: s = 0; 3: if i >= n goto 9; 4: t = a[i]; 5: if t < 0 goto 7; 6: s = s + t; 7: i = i + 1; 8: goto 3; 9: print s; 10: halt
- A. 5
- B. 6
- C. 7
- D. 8
Correct answer: B. 6
Leaders (instruction numbers): 1, 3, 4, 6, 7, 9 — first instruction, jump targets and instructions after jumps — so 6 blocks.
More Compiler Design questions
- Using Sethi–Ullman numbering (a leaf that is a left operand needs 1 register, a leaf that is a right operand can be used from memory and…
- Grammar: S → A B D; A → a A | ε; B → b B | A c | ε; D → d D | ε. What is |FOLLOW(A)| + |FOLLOW(B)| + |FOLLOW(D)|? (FOLLOW sets may contain…
- Grammar: E → T X; X → + T X | − T X | ε; T → F Y; Y → F Y | / F Y | ε; F → ( E ) | id | num | − F. How many non-empty cells does its LL(1)…
- How many states does the canonical LR(0) automaton have for the augmented grammar S' → S, S → a S b | a b?
- Program: int x = 5; int f() { return x; } int g() { int x = 7; return f() + x; } int h() { int x = 11; return g() + f() + x; } main calls…
- The expression ((((a + b) + c) ((a + b) + d)) - ((a + b) ((a + b) + c))) is stored as a DAG with common subexpressions shared (no…