All mock tests are FREE till 31 December — register to save your progress

Consider the two grammars: G₁: S → SbS | a G₂: S → aB | ab, A → AAB | a, B → ABb | b Which of the following options is correct?

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: C. Both G₁ and G₂ are ambiguous

Explanation

In G₁, ababa has two parse trees (group left or right). In G₂, ab comes from S → ab directly and from S → aB → ab. Both are ambiguous.

More Theory of Computation and Compilers questions