GATE / CS ARCHIVE

GATE CSE 2011 / QUESTION 26

Equal three-block language is not context-free

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

GATE 2011, Q26 2 marks · MCQ
Report issue

Context-Free Grammars & Languages

Question 26, GATE 2011: Let L1={0^p1^q : p,q in N}, L2={0^p1^q : p=q in N}, and L3={0^p1^q0^r : p=q=r in N}. Which statement is NOT TRUE?

(A) A PDA can recognize L1 and L2
(B) L1 is regular
(C) All three languages are context-free
(D) Turing machines can recognize all three languages
Tap to enlarge
Your answer
Answer & solution

Official answer: C

L1=0*1* is regular and hence recognizable by a PDA; L2 matches two block lengths and is context-free. L3={0n1n0n} is not context-free: for pumping length p, choose 0p1p0p. A pumping window of length≤p cannot reach both outer zero blocks. Pumping a nonempty part therefore changes at most two blocks while leaving another unchanged, or destroys the block order, so equality of all three counts fails. All three are decidable by a Turing machine. Thus the claim that all three are context-free is false, C.

A PDA for L2 pushes one marker per initial 0 and pops one per following 1, rejecting if lengths differ or block order is wrong. L1 does not even need the stack. L3 requires coordinating three unbounded block lengths, and the pumping argument establishes the failure of context-freeness rather than merely asserting that a particular PDA design fails. A Turing machine can repeatedly mark one symbol in each block, so the failure is specific to context-free recognition, not computability.

Original paper, page 7 · Answer key