All mock tests are FREE till 31 December — register to save your progress
Unit 8 · Theory of Computation and Compilers Paper 2 CS · September 2022

Consider the grammar S → SbS | a. The string abababa has (A) two parse trees (B) two leftmost derivations (C) two rightmost derivations. Which is correct?

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

Show answer & explanation

Correct answer: A. All (A), (B) and (C) are true

Explanation

The grammar is ambiguous: abababa has several parse trees (it has four b's to split on — 5 trees in all). Each parse tree has its own leftmost and rightmost derivation, so (A), (B) and (C) all hold.

More Theory of Computation and Compilers questions