Consider the context-free grammars over the alphabet {a,b,c} given below. S and T are non-terminals. G1: S → aSb | T, T → cT | G2: S → bSa | T, T → cT | The language L(G1) ∩ L(G2) is
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2017 Set 1 · Q37
Time
Select one answerSingle correct
Solution
Official answer: B) Not finite but regular.
Context-Free Grammars and PDAsFrom the grammar :
generates equal numbers of 's at the beginning and 's at the end surrounding .
generates any number of 's ().
Thus, .
From the grammar :
generates equal numbers of 's at the beginning and 's at the end surrounding .
generates .
Thus, .
To find the intersection :
For , any non-empty string generated with in starts with and ends with , whereas in it starts with and ends with . They share no common strings for .
For , both grammars generate , which produces strings in .
Hence, .
The language is infinite (not finite) and regular, which corresponds to option (B).
Try the question first, then check your work.
Examiner trap
Determine the set of strings generated by both grammars: strings in have the form while strings in have the form .
This Context-Free Grammars and PDAs previous year question is Q37 of the GATE CSE 2017 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 2-mark MCQs like this one, and GATE CSE 2017 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.