Which one of the following languages over = {a, b} is NOT context-free?
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2019 · Q31
Time
Select one answerSingle correct
Solution
Official answer: C) {wan wR bn w ∈ {a, b}*, n ≥ 0}
Regular and Context-Free LanguagesLet us analyze each language:
(A) : This is the language of even-length palindromes, which is standard non-deterministic context-free (a PDA pushes and pops on guessing the midpoint to match ).
(B) : A PDA can push onto the stack, then push and pop on matching , and finally pop the remaining to match . Because the stack operates in LIFO order, is fully processed and cleared before matching with . Hence, this is context-free.
(C) : To check and , the stack must be used to match them. However, the count of must also be compared with appearing *after* . Since the stack must clear/compare with first, the count of cannot be retained simultaneously using a single pushdown stack. Using the Pumping Lemma for CFLs, it can be proven that is NOT context-free.
(D) : This is a finite union of three context-free languages, and since CFLs are closed under union, is context-free.
Therefore, the language in option (C) is not context-free.
Try the question first, then check your work.
Examiner trap
Check whether a single pushdown stack (LIFO) can simultaneously match with while remembering the count to compare and when they are separated.
This Regular and Context-Free Languages previous year question is Q31 of the GATE CSE 2019 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 GATE CSE 2019 has 3.
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.