GATE Computer ScienceVery hardGATE CS (PYQ pattern)

For G: S → A S | b; A → S A | a, which statements are true? I. FOLLOW(A) ⊂ FOLLOW(S) (proper subset). II. The LL(1) table has exactly two multiply-defined cells, M[S, b] and M[A, a]. III. G is ambiguous. IV. G is SLR(1).

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

Correct answer: C. I, II and III only

FIRST(S) = {a, b} = FIRST(A). FOLLOW(S) = {$} ∪ FIRST(A) = {$, a, b} (S → A S makes S end S; A → S A puts FIRST(A) after S); FOLLOW(A) = FIRST(S) ∪ FOLLOW(A) = {a, b}; $ never follows A, so I holds. S → A S and S → b both go to M[S, b]; A → S A and A → a both to M[A, a]. a b a b has two trees, so G is ambiguous and cannot be SLR(1).

More Compiler Design questions

Exams that ask this topic