GATE Computer ScienceVery hardGATE CS (PYQ pattern)

For G: S → A b | a A c | B c | a B b; A → a; B → a, which statements are true? I. G is LL(2). II. G is SLR(1). III. G is LALR(1). IV. The LALR(1) and canonical LR(1) automata have the same number of states.

  1. A. II, III and IV only
  2. B. I, III and IV only
  3. C. III and IV only
  4. D. III only

Correct answer: C. III and IV only

I: a a c (from a A c) and a a b (a B b) share the 2-prefix a a: not LL(2) (it is LL(3)). II: FOLLOW(A) = FOLLOW(B) = {b, c}, so both states {A → a·, B → a·} have reduce-reduce clashes. III/IV: the state after a alone reduces A on b, B on c; after a a it reduces A on c, B on b. Those two states have different cores (the first also holds S → a·A c, S → a·B b), so no core is split and LALR = LR(1), conflict-free.

More Compiler Design questions

Exams that ask this topic