Consider the following languages over the alphabet = {a, b, c}. Let L1 = { an bn cm m, n ≥ 0 } and L2 = { am bn cn m, n ≥ 0 }. Which of the following are context-free languages? I. L1 ∪ L2 II. L1 ∩ L2
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2017 Set 1 · Q38
Time
Select one answerSingle correct
Solution
Official answer: A) I only
Regular and Context-Free LanguagesContext-freeness of and :
is context-free because a single pushdown automaton (PDA) can push 's and pop them on matching 's, then accept any number of 's.
is context-free because a PDA can skip any number of 's, push 's, and pop them on matching 's.
Statement I ():
Context-free languages are closed under union.
Since both and are CFLs, is context-free.
Statement II ():
, which is a standard non-context-free language (it requires two independent count comparisons, which a single stack cannot perform).
Therefore, only statement I is context-free, making (A) the correct choice.
Try the question first, then check your work.
Examiner trap
Context-free languages are closed under union, but not closed under intersection.
This Regular and Context-Free Languages previous year question is Q38 of the GATE CSE 2017 Set 1 paper. Find more GATE CSE PYQs on Regular and Context-Free Languages 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 Regular and Context-Free Languages 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.
Regular and Context-Free Languages has 21 GATE CSE PYQs across 13 papers from 2011 to 2026. 9 of them are 2-mark MCQs like this one, and it is the only one in GATE CSE 2017 Set 1.
How GATE tests Regular and Context-Free LanguagesIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.