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?

  1. A. 12 and 13; a shift-reduce conflict
  2. B. 12 and 14; a reduce-reduce conflict
  3. C. 12 and 13; a reduce-reduce conflict
  4. 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

Exams that ask this topic