Skip to content
Mad4Study

Engineering & Science

GATE Computer Science

  • GATE CS
  • 2026–27 pattern practice
  • Theory of Computation
  • Context-free grammars
  • Easy

The grammar E→E+E∣E∗E∣idE \to E + E \mid E * E \mid \mathit{id} is

Context-Free Languages

Pick an option to check your answer.

id+id∗id\mathit{id} + \mathit{id} * \mathit{id} has two leftmost derivations (two parse trees): one grouping (id+id)∗id(\mathit{id} + \mathit{id}) * \mathit{id}, the other id+(id∗id)\mathit{id} + (\mathit{id} * \mathit{id}). Two parse trees for one string means the grammar is ambiguous.

Why not the others

  • unambiguous is disproved by the example.
  • regular — it is self-embedding and generates nested expressions.
  • LL(1) — it is left-recursive and ambiguous, so it cannot be.

Report an error

GATE CS · Theory of Computation · Context-Free Languages