GateAI
Context-Free Grammars and PDAs

GATE CSE 2016 Set 1 · Q16

MCQ1 markEasy

Time

Which of the following languages is generated by the given grammar? S⟶aS∣bS∣εS \longrightarrow aS \mid bS \mid \varepsilon

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: D) {a, b}*

Context-Free Grammars and PDAs

Given the grammar rules:

S→aS∣bS∣εS \rightarrow aS \mid bS \mid \varepsilon

From the start symbol SS:

  • By choosing S→aSS \rightarrow aS, an 'a' is prefixed.

  • By choosing S→bSS \rightarrow bS, a 'b' is prefixed.

  • By choosing S→εS \rightarrow \varepsilon, the derivation terminates.

Thus, at any step, either 'a' or 'b' can be generated independently, and the derivation can terminate at any length including 00 (the empty string ε\varepsilon). This generates any string consisting of arbitrary combinations of aa's and bb's.

Therefore, the language generated is (a+b)∗={a,b}∗(a+b)^* = \{a, b\}^*, which corresponds to option (D).

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

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

Where do you stand for GATE?

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.

One GATE CSE PYQ every morning

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 in GATE CSE

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 PDAs

More from GATE CSE 2016 Set 1

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2016 Set 1 · Q16 · MCQ

Which of the following languages is generated by the given grammar? S aS bS

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.