Which of the following languages is generated by the given grammar? S aS bS
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2016 Set 1 · Q16
Time
Select one answerSingle correct
Solution
Official answer: D) {a, b}*
Context-Free Grammars and PDAsGiven the grammar rules:
From the start symbol :
By choosing , an 'a' is prefixed.
By choosing , a 'b' is prefixed.
By choosing , the derivation terminates.
Thus, at any step, either 'a' or 'b' can be generated independently, and the derivation can terminate at any length including (the empty string ). This generates any string consisting of arbitrary combinations of 's and 's.
Therefore, the language generated is , which corresponds to option (D).
Try the question first, then check your work.
Examiner trap
Notice that from the start variable , you can choose to append either or indefinitely before terminating with .
This Context-Free Grammars and PDAs previous year question is Q16 of the GATE CSE 2016 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. 9 of them are 1-mark MCQs like this one, and GATE CSE 2016 Set 1 has 3.
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.