GATE / CS ARCHIVE

GATE CSE 2006 / QUESTION 19

Context-free block-count languages

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

GATE 2006, Q19 1 mark · MCQ
Report issue

Context-Free Grammars & Languages

Question 19, GATE 2006: For n,m≥0 define L₁={0^(n+m)1^n0^m}, L₂={0^(n+m)1^(n+m)0^m}, and L₃={0^(n+m)1^(n+m)0^(n+m)}. Which languages are not context-free?
Options:
(A) L₁ only
(B) L₃ only
(C) L₁ and L₂
(D) L₂ and L₃
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

1. L1={0n+m1n0m} is context-free: S→0S0|T and T→0T1|ε generates it. Write L2={0k1k0m:0≤m≤k}.

2. It is not context-free: apply the CFL pumping lemma to 0p1p0p. A pump confined to one block breaks either equality of the first two block lengths or the last≤first inequality (choose pumping direction accordingly).

3. A pump crossing one boundary cannot touch all three blocks; preserving the first two lengths while pumping down makes the third too long, while other changes break equality or block order. L3 is{0k1k0k:k≥0}, also non-context-free by the usual three-block pumping argument.

4. Hence L2 and L3, D.

5. Teaching check: For L₂ the two equal leading block lengths and the upper bound on the final block are linked. A pumping window of length p cannot span all three p-length blocks in 0p1p0p. Even if it changes the first two blocks equally, pumping down leaves the untouched third block too long.

Original paper, page 3