Skip to content
Official PYQ · 1987

GATE CS 1987 Q1-xii — Parsing (LL, LR)

Explain with AI

A context-free grammar is ambiguous if:

Choose one option
View worked solution

Answer: B

By definition, a context-free grammar (CFG) GG is ambiguous if there exists at least one string w∈L(G)w \in L(G) that has more than one distinct parse tree (or equivalently, more than one leftmost derivation or rightmost derivation).

Let's evaluate the given options:

  • Option A: Useless non-terminals are symbols that cannot derive any terminal string or cannot be reached from the start symbol. Their presence does not determine whether a grammar is ambiguous.
  • Option B: This directly matches the standard definition of ambiguity.
  • Option C: Having adjacent non-terminals on the right-hand side (e.g., A→BCA \rightarrow BC) is a standard feature of many unambiguous grammars, such as those in Chomsky Normal Form (CNF). It does not imply ambiguity.

Therefore, the correct option is B.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Parsing (LL, LR) questions