GATE Computer ScienceEasyGATE CS (PYQ pattern)
How many distinct LR(0) items does the grammar E → T E'; E' → + T E' | ε; T → F T'; T' → * F T' | ε; F → ( E ) | id have (do not augment it; an ε-production gives exactly one item)?
- A. 24
- B. 22
- C. 14
- D. 25
Correct answer: B. 22
A production with right side of length m gives m + 1 items (dot positions); summing over the 8 productions gives 22.
More Compiler Design questions
- Dead-code elimination deletes every assignment whose target is not live immediately after it (live-variable analysis), and is repeated…
- Same function f(n) = 1 for n ≤ 2, else f(n − 1) + f(n − 2) + f(n − 3). Each activation record takes 28 bytes. What is the maximum stack…
- The SLR(1) table of S → i E t S Z | a; Z → e S | ε; E → b has one shift-reduce conflict (shift e versus reduce Z → ε), resolved as yacc…
- G: S → a A d | b B d | a B e | b A e; A → c; B → c is LR(1) but not LALR(1). Which of these changes, each made on its own, makes the…
- Sethi–Ullman labelling (a leaf is 1 if it is a left child and 0 if it is a right child, since a right operand may come from memory; an…
- An SDD uses N → B N1 { N.val = B.val + 2 × N1.val } | B { N.val = B.val } and B → 0 { B.val = 0 } | 1 { B.val = 1 }. What is N.val at the…