GATE Computer ScienceVery hardGATE CS (PYQ pattern)

For G: S → a E c | a F d | b F c | b E d; E → e; F → e, what is the smallest k for which G is LL(k), and is G LALR(1)?

  1. A. k = 2; G is LALR(1)
  2. B. k = 3; G is LALR(1)
  3. C. no such k; G is not LALR(1)
  4. D. k = 3; G is not LALR(1)

Correct answer: D. k = 3; G is not LALR(1)

a E c and a F d both begin a e, so 2 symbols are not enough; the third symbol (c or d) decides: LL(3). For LR, after a e the state reduces E on c and F on d, and after b e it reduces F on c and E on d. Same core, swapped lookaheads: canonical LR(1) is fine, but merging gives reduce-reduce conflicts on c and d.

More Compiler Design questions

Exams that ask this topic