Consider the following two languages over the alphabet {a, b, c}, where m and n are natural numbers. L1 = {am bm cm+n m, n ≥ 1} L2 = {am bn cm+n m, n ≥ 1} Which ONE of the following statements is CORRECT?
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2025 Set 1 · Q45
Time
Select one answerSingle correct
Solution
Official answer: C) L1 is not a context-free language but L2 is a context-free language.
Regular and Context-Free Languages### Analysis of Language :
In , there are two simultaneous conditions tied to the same parameter :
The number of 's must equal the number of 's ().
The number of 's must be at least (i.e., with ).
A Pushdown Automaton (PDA) has only one stack. If it pushes 's and matches them against 's, the stack becomes empty and cannot remember to ensure that the number of 's is .
Using the Pumping Lemma for CFLs:
Choose , where is the pumping length.
Any decomposition with and cannot maintain both the equality between 's and 's and the condition that the count of 's is greater than the count of 's and 's upon pumping.
Hence, is not a context-free language.
---
### Analysis of Language :
In , the total number of 's equals the sum of the number of 's and 's. A PDA can easily recognize this language:
Push all 's onto the stack.
Push all 's onto the stack.
For each read from the input, pop one symbol from the stack (first popping all 's, then all 's).
Accept if the stack is empty after consuming the input (with ).
A Context-Free Grammar (CFG) for can be given as:
Hence, is a context-free language.
Therefore, is not context-free but is context-free, which corresponds to option (C).
Try the question first, then check your work.
Examiner trap
Check how many independent comparisons are required. A single stack PDA can verify that the sum of 's and 's equals the number of 's (), but cannot simultaneously verify that the count of 's equals 's while also comparing against the count of 's ().
This Regular and Context-Free Languages previous year question is Q45 of the GATE CSE 2025 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 GATE CSE 2025 Set 1 has 2.
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.