GateAI
Regular and Context-Free Languages

GATE CSE 2025 Set 1 · Q45

MCQ2 marksMedium

Time

Consider the following two languages over the alphabet {a,b,c}\{a, b, c\}, where mm and nn are natural numbers. L1={ambmcm+n∣m,n≥1}L_1 = \{a^m b^m c^{m+n} \mid m, n \ge 1\} L2={ambncm+n∣m,n≥1}L_2 = \{a^m b^n c^{m+n} \mid m, n \ge 1\} Which ONE of the following statements is CORRECT?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified 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 L1L_1:

L1={ambmcm+n∣m,n≥1}L_1 = \{a^m b^m c^{m+n} \mid m, n \ge 1\}

In L1L_1, there are two simultaneous conditions tied to the same parameter mm:

  1. The number of aa's must equal the number of bb's (mm).

  2. The number of cc's must be at least m+1m + 1 (i.e., m+nm+n with n≥1n \ge 1).

A Pushdown Automaton (PDA) has only one stack. If it pushes aa's and matches them against bb's, the stack becomes empty and cannot remember mm to ensure that the number of cc's is m+nm+n.

Using the Pumping Lemma for CFLs:

  • Choose w=apbpcp+1∈L1w = a^p b^p c^{p+1} \in L_1, where pp is the pumping length.

  • Any decomposition w=uvxyzw = uvxyz with ∣vxy∣≤p|vxy| \le p and ∣vy∣≥1|vy| \ge 1 cannot maintain both the equality between aa's and bb's and the condition that the count of cc's is greater than the count of aa's and bb's upon pumping.

  • Hence, L1L_1 is not a context-free language.

---

### Analysis of Language L2L_2:

L2={ambncm+n∣m,n≥1}L_2 = \{a^m b^n c^{m+n} \mid m, n \ge 1\}

In L2L_2, the total number of cc's equals the sum of the number of aa's and bb's. A PDA can easily recognize this language:

  1. Push all aa's onto the stack.

  2. Push all bb's onto the stack.

  3. For each cc read from the input, pop one symbol from the stack (first popping all bb's, then all aa's).

  4. Accept if the stack is empty after consuming the input (with m,n≥1m, n \ge 1).

A Context-Free Grammar (CFG) for L2L_2 can be given as:

  • S→aSc∣aAcS \to aSc \mid aAc

  • A→bAc∣bcA \to bAc \mid bc

Hence, L2L_2 is a context-free language.

Therefore, L1L_1 is not context-free but L2L_2 is context-free, which corresponds to option (C).

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 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

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 Regular and Context-Free Languages 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.

Regular and Context-Free Languages in GATE CSE

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 Languages

More from GATE CSE 2025 Set 1

Share this solution

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

GateAI solution cardGATE CSE 2025 Set 1 · Q45 · MCQ

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

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