Question
Which of the following grammars is/are ambiguous?
Official answer and solution
- Official answer
- B and C
- From
- Official GATE 2026 answer key
Solution
Check whether each grammar admits two distinct parse trees (or leftmost derivations) for some string.
- (A) generates uniquely; it is unambiguous.
- (B) is the classic ambiguous expression grammar (e.g., and each have two parse trees).
- (C) is ambiguous because the string has two distinct leftmost derivations: and .
- (D) is a right-linear deterministic grammar generating unambiguously.
Thus (B) and (C) are ambiguous.
Final answer
Options (B), (C)
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2026 Computer Science and Information Technology - Session 2 (CS2)
- Question
- 29 of 65
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.