Consider the following two grammars G₁ S → S b S / a G₂ S → aB / ab A → AB / a…
2018
Consider the following two grammars
G₁
S → S b S / a
G₂
S → aB / ab
A → AB / a
B → Abb / b
- A.
Only G₁ is ambiguous
- B.
Only G₂ is ambiguous
- C.
Both G₁ and G₂ are ambiguous
- D.
Both G₁ and G₂ are not ambiguous
Attempted by 72 students.
Show answer & explanation
Correct answer: C
Grammar G₁ (S → S b S | a) is ambiguous because strings like 'aba' have multiple parse trees. Standard compiler design analysis classifies G₂ as ambiguous as well. Therefore, the option identifying G₁'s ambiguity is correct.
A video solution is available for this question — log in and enroll to watch it.