Consider the following grammar: S → aSbS | bS | ϵ. Which of the following is true?
Solution :
The correct option is: Grammar is ambiguous.
A grammar is defined as ambiguous if there exists at least one string in its language that has more than one leftmost derivation, more than one rightmost derivation, or more than one distinct parse tree.
Let us consider the given grammar rules:
S → aSbS | bS | ϵ
To prove that the grammar is ambiguous, we can demonstrate that a simple string generated by this grammar, such as "ab", has more than one distinct parse tree (or leftmost derivation).
Let's derive the string "ab" using two different leftmost derivations:
Leftmost Derivation 1:
S ⇒ aSbS (using S → aSbS)
S ⇒ a(ϵ)bS (replacing the first S with ϵ)
S ⇒ abS
S ⇒ ab(ϵ) (replacing S with ϵ)
S ⇒ ab
Leftmost Derivation 2:
S ⇒ aSbS (using S → aSbS)
S ⇒ aSb(ϵ) (replacing the second S with ϵ)
S ⇒ aSb
S ⇒ a(ϵ)b (replacing S with ϵ)
S ⇒ ab
Since the string "ab" can be derived using two distinct leftmost derivations, it has two distinct parse trees. Therefore, the grammar is ambiguous.
Completely free for students. Educators & coaching institutes get 2 months free Pro trial to create tests.
Access unlimited practice questions, detailed step-by-step solutions, and exam study materials — completely free for students.
Create and conduct professional online assessments with AI question generation, tab proctoring, and comprehensive batch management.
Prepare for GATE 2026 Civil Engineering with the latest question papers, previous year papers, detailed solutions, syllabus, exam pattern, preparation tips, mock tests, and subject-wise study material. Download GATE 2026 CE question papers with solutions in PDF format and boost your preparation for top engineering institutes and PSU recruitment.
Prepare effectively for GATE 2026 Electronics & Communication Engineering (EC) with this comprehensive Question Paper with Solutions. This resource includes detailed explanations, concept-wise solutions, previous year paper analysis, and exam-oriented practice to help aspirants strengthen core subjects like Electronic Devices, Analog Circuits, Digital Circuits, Signals & Systems, Network Theory, Control Systems, Electromagnetics, Communications, and more. Perfect for revision, self-assessment, and boosting your GATE 2026 EC preparation strategy.
Copyright © 2026 Combe Labs Private Limited. All Rights Reserved.