GATE Computer ScienceVery hardGATE CS (PYQ pattern)
For S → A a | b A c | B c | b B a; A → d; B → d (augmented), how many states do the LR(0) and canonical LR(1) automata have, and what does merging LR(1) states into LALR(1) produce?
- A. 12 and 13; a shift-reduce conflict
- B. 12 and 14; a reduce-reduce conflict
- C. 12 and 13; a reduce-reduce conflict
- D. 11 and 13; no conflict
Correct answer: C. 12 and 13; a reduce-reduce conflict
After d at the start: {A → d· (a), B → d· (c)}; after b d: {A → d· (c), B → d· (a)}. Same core, different lookaheads: two LR(1) states where LR(0) has one, so 13 versus 12. Merging them gives A → d· and B → d· both on {a, c}: a reduce-reduce conflict (merging can never create a shift-reduce one).
More Compiler Design questions
- The grammar S → S S S | a is ambiguous. How many distinct parse trees do the strings a⁷ (seven a's) and a⁶ (six a's) have, respectively?
- Build the SLR(1) table of the ambiguous grammar E → E + E | E E | id (augmented with S′ → E). How many LR(0) states are there, and how…
- For S → A a A b | B b B a; A → ε; B → ε (augmented), how many ACTION cells are multiply defined in the LR(0), SLR(1) and LALR(1) tables…
- For G: S → a A c | a B d | B c; A → z; B → z, which statements are true? I. The canonical LR(1) automaton has the same number of states as…
- S → a S | b S | c is LR(0). In its LR(0) parsing table the reduce action for a complete item is written in every terminal column including…
- For the production A → B C D (A.i, B.i, C.i, D.i inherited; A.s, B.s, C.s, D.s synthesised), which rule set makes the SDD L-attributed?