Consider the following grammar S ⟶ 0S1|1S0|SS|∈ Consider the following…

Consider the following grammar

S ⟶ 0S1|1S0|SS|∈

Consider the following statements:

S1: The grammar is ambiguous.

S2: The grammar generates language in which every string start and end with different symbols.

Select the correct option.

Answer: A. S1 is true and S2 is falseThe grammar is ambiguous as two parse trees can represent epsilon. Parse tree 1: S-> ϵ Parse tree 2: S-> SS -> ϵϵ The grammar doesn’t generate language in…

  1. A.

     S1 is true and S2 is false

  2. B.

     Both S1 and S2 are true

  3. C.

     S1 is false and S2 is true

  4. D.

    Both S1 and S2 are false

Attempted by 100 students.

Show answer & explanation

Correct answer: A

The grammar is ambiguous as two parse trees can represent epsilon.

Parse tree 1: S-> ϵ

Parse tree 2: S-> SS -> ϵϵ

The grammar doesn’t generate language in which every string start and end with different symbols. For ex: grammar generates string “0110”.

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…