GATE Computer ScienceHardGATE CSE · UGC NET
A basic block is: t1 = a + b; t2 = a − b; t3 = t1 * t2; t4 = a + b; t5 = t4 * t2; t6 = t3 + t5; y = t6 / t3. How many nodes (leaves included) does its DAG have?
- A. 6
- B. 7
- C. 8
- D. 9
Correct answer: B. 7
Leaves a and b (2); a+b (shared by t1 and t4), a−b, (a+b)*(a−b) (shared by t3 and t5), t3 + t3 and the final division: 5 operator nodes, total 7.
More Compiler Design questions
- The interference graph of six variables v0–v5 has edges v0 with each of v1–v5, plus the cycle v1–v2–v3–v4–v5–v1. What is the minimum…
- Using E → E + T | T; T → T F | F; F → ( E ) | id, how many nodes (terminal leaves included) does the parse tree of id + id id id + id have?
- After local common-subexpression elimination, algebraic simplification (x + 0, x 1), copy propagation and dead-code elimination, how many…
- Left factoring is applied to A → a b c | a b d | a e | f, and the shared prefixes are factored as far as possible, with new non-terminals…
- How many cells of the LL(1) parsing table of E → T E′; E′ → + T E′ | ε; T → F T′; T′ → F T′ | ε; F → ( E ) | id contain a production?…
- How many states does the canonical LR(0) collection of the augmented grammar S′ → S; S → a S b | a b have, and how many of them have a…