Consider the following grammar where S is the start symbol, and a and b are terminal symbols. S → aSbS bS Which of the following statements is/are true?
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2026 Set 1 · Q25
Time
Select all that applyOne or more correct
Solution
Official answer: A) The grammar is ambiguous; B) The string abb has two distinct derivations in this grammar; C) The string abab has only one rightmost derivation
Context-Free Grammars and PDAsLet us analyze each statement based on the grammar :
Ambiguity and Derivations for (Statements A and B): Consider the string :
Derivation 1:
Derivation 2:
Because there exist two distinct parse trees (and therefore two distinct leftmost/rightmost derivations) for the string , the string has two distinct derivations and the grammar is ambiguous. Hence, (A) and (B) are true.
Derivation for (Statement C): Let us find the rightmost derivation for :
There is no other valid derivation sequence to generate . Since it produces a unique parse tree, has only one rightmost derivation. Thus, (C) is true.
Decidability (Statement D): The language generated by this context-free grammar is a context-free language (CFL). All context-free languages are decidable. Therefore, statement (D) is false.
Hence, the correct statements are A, B, and C.
Try the question first, then check your work.
Examiner trap
Try constructing two different parse trees for the string by placing the first in different positions. Remember that all context-free languages are decidable.
This Context-Free Grammars and PDAs previous year question is Q25 of the GATE CSE 2026 Set 1 paper. Find more GATE CSE PYQs on Context-Free Grammars and PDAs in Theory of Computation, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Context-Free Grammars and PDAs PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Context-Free Grammars and PDAs has 26 GATE CSE PYQs across 17 papers from 2011 to 2026. 2 of them are 1-mark MSQs like this one, and GATE CSE 2026 Set 1 has 2.
How GATE tests Context-Free Grammars and PDAsIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.