If G is a grammar with start symbol S and productions S → S1S | 0S1 | 1S0 | SS…

If G is a grammar with start symbol S and productions

S → S1S | 0S1 | 1S0 | SS | ε

then select the correct option.

Answer: D. None of the aboveCorrect answer: None of the above. The grammar is ambiguous. For the string ε, we can derive it in two different ways: 1. S ⇒ ε 2. S ⇒ SS ⇒ εε ⇒ ε These…

  1. A.

    The grammar is LL(1)

  2. B.

    The grammar is LR(1), but not LALR(1)

  3. C.

    The grammar is SLR(1), but not LR(0)

  4. D.

    None of the above

Attempted by 65 students.

Show answer & explanation

Correct answer: D

Correct answer: None of the above.

The grammar is ambiguous. For the string ε, we can derive it in two different ways:

1. S ⇒ ε
2. S ⇒ SS ⇒ εε ⇒ ε

These correspond to different parse trees for the same string. Therefore, the grammar is ambiguous.

Every LL(1), LR(0), SLR(1), LALR(1), and LR(1) grammar is unambiguous. Since this grammar is ambiguous, options 1, 2, and 3 are false. Hence, option 4 is correct.

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…