GATE Computer ScienceHardGATE CS (PYQ pattern)

For G: S → A A; A → a A | b | ε, which statements are true? I. FOLLOW(A) = {a, b, $}. II. G is LL(1). III. G is ambiguous. IV. G is LR(1).

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

Correct answer: C. I and III only

FOLLOW(A) gets FIRST(A) − ε = {a, b} from S → A A and FOLLOW(S) = {$} because the second A ends S: I true. The string a has two trees (first A = a, second ε; or first ε, second a), so G is ambiguous (III true) and therefore neither LL(1) (M[A, a] holds A → a A and A → ε) nor LR(1).

More Compiler Design questions

Exams that ask this topic