A grammar that is both left and right recursive for a non-terminal is
1999
A grammar that is both left and right recursive for a non-terminal is
- A.
Ambiguous
- B.
Unambiguous
- C.
Information is not sufficient to decide whether it is ambiguous or Unambiguous.
- D.
None of the above
Attempted by 42 students.
Show answer & explanation
Correct answer: A
The correct answer is: Ambiguous.
If a grammar is both left recursive and right recursive for the same non-terminal, then the same generated string can be derived in two structurally different ways. One derivation expands the recursive occurrence on the left, and another expands it on the right.
This gives two different parse trees for at least one string in the language of the grammar. Therefore, the grammar is ambiguous.
So the correct option is Ambiguous.