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

  1. A.

    Only G₁ is ambiguous

  2. B.

    Only G₂ is ambiguous

  3. C.

    Both G₁ and G₂ are ambiguous

  4. 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.

Explore the full course: Mppsc Assistant Professor