Skip to content
Official PYQ · 2004

GATE CS 2004 Q87 — Regular and Context-free Languages

Explain with AI

The language {ambncm+n∣m,n≥1}\left\{a^mb^nc^{m+n} \mid m, n \geq1\right\} is

Choose one option
View worked solution

Answer: B

The given language is L={ambncm+n∣m,n≥1}L = \{a^m b^n c^{m+n} \mid m, n \geq 1\}.

1. Why is LL not Regular?
To recognize strings in LL, we need to remember the count of aa's (mm) and bb's (nn) to ensure that the number of cc's is exactly m+nm+n. Since mm and nn can be arbitrarily large, a Finite Automaton (which has finite memory) cannot keep track of these counts. Thus, LL is not regular.

2. Why is LL Context-Free?
We can design a Pushdown Automaton (PDA) that uses a single stack to accept LL as follows:

  • For every aa read from the input, push a symbol AA onto the stack.
  • For every bb read from the input, push a symbol BB onto the stack. At this point, the stack contains mm copies of AA at the bottom and nn copies of BB on top.
  • When cc's start arriving:
    • Pop a BB for each of the first nn cc's.
    • Pop an AA for each of the next mm cc's.
  • If the input is completely consumed and the stack is empty (except for the initial stack symbol), accept the string.
Since a PDA can recognize LL, the language is context-free.

Therefore, the language is context-free but not regular.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Regular and Context-free Languages questions