GATE Computer ScienceEasyGATE CS (PYQ pattern)

Which of the following is/are true for the grammar S → a S | S b | c? I. It is ambiguous. II. It is LL(1). III. It is SLR(1). IV. It is LR(1) but not SLR(1).

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

Correct answer: A. I only

The string a c b has two parse trees (a S then S b, or S b then a S), so the grammar is ambiguous; ambiguous grammars are never LL(1) or LR(k).

More Compiler Design questions

Exams that ask this topic