GATE Computer ScienceVery hardGATE CS (PYQ pattern)

Construct the LL(1) table of S → A B c | B d; A → a A | ε; B → b B | A. Which option lists exactly the multiply-defined cells?

  1. A. M[S, a] and M[S, b] only
  2. B. M[S, a], M[S, b] and M[A, a]
  3. C. M[S, a], M[A, a] and M[B, a]
  4. D. M[S, a], M[S, b], M[A, a] and M[B, a]

Correct answer: B. M[S, a], M[S, b] and M[A, a]

A and B are nullable. FIRST(A B c) = {a, b, c}, FIRST(B d) = {a, b, d}: clash on a and b. FOLLOW(B) = {c, d}, and B → A makes FOLLOW(A) ⊇ FOLLOW(B); S → A B c adds FIRST(B c) = {a, b, c}, so FOLLOW(A) = {a, b, c, d}. Hence A → ε also lands in M[A, a] beside A → a A. M[B, a] holds only B → A (B → b B is under b), so it is not a conflict.

More Compiler Design questions

Exams that ask this topic