GATE / CS ARCHIVE

GATE CSE 2004 / QUESTION 87

Classify a language with additive block counts

Theory of Computation · Context-Free Grammars & Languages · Full GATE CSE 2004 paper

GATE 2004, Q87 2 marks · MCQ
Report issue

Context-Free Grammars & Languages

Question 87, GATE 2004: Classify L={a^m b^n c^(m+n):m,n≥1}.
Options:
(A) Regular
(B) Context-free but not regular
(C) Context-sensitive but not context-free
(D) Type-0 but not context-sensitive
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. For L={am bn cm+n:m,n≥1}, a context-free grammar is S→aSc | aTc and T→bTc | bc. The outer recursion supplies matching a/c pairs and the inner recursion matching b/c pairs, so it generates exactly L.

2. It is not regular: for a putative pumping length p, use ap b cp+1. Any pumpable segment within the first p symbols consists only of a characters; pumping changes the a count without changing the c count, violating the defining equality.

3. Therefore context-free but not regular, B.

4. Teaching check: A pushdown automaton can push one marker for each a and b, then pop one for each c, while tracking the required block order and nonempty a,b blocks. A finite automaton cannot maintain the unbounded count equality; the pumping argument makes this limitation rigorous.

Original paper, page 12