GATE / CS ARCHIVE

GATE CSE 2022 / QUESTION 48

GATE CSE 2022 Q48

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

GATE 2022, Q48 2 marks · MSQ
Report issue

Context-Free Grammars & Languages

Question 48, GATE 2022: L1={ww:w∈{a,b}*}, L2={a^n b^n c^m:m,n≥0}, L3={a^m b^n c^n:m,n≥0}. Select FALSE claims: A L1 not context-free, L2/L3 deterministic context-free; B neither L1 nor L2 context-free; C L2,L3 and their intersection all context-free; D neither L1 nor its complement context-free.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: B,C,D

The copy language L1={ww} is not context-free: intersecting with a+b+a+b+ gives {aⁱbʲaⁱbʲ: i, j>0}. For pumping length p, aᵖbᵖaᵖbᵖ has any pumping window of length at most p within at most two adjacent blocks. Pumping changes at least one block without changing its matching nonadjacent block, or creates extra alternations, contradicting this language’s form. L2 and L3 are deterministic context-free by pushing one block and matching the adjacent equal-count block; their intersection is {aⁿbⁿcⁿ}, not context-free. Thus A is true and B, C are false. D is also false because the complement of L1 is context-free: include all odd-length words, and for even length choose two different symbols in corresponding half-positions. Let Ea={uav:|u|=|v|} and Eb={ubv:|u|=|v|}; each is context-free via Sa→cS_a d | a for c, d∈Σ, and similarly Sb. E_aE_b ∪ E_bE_a describes exactly the even noncopies, since the two centers differ and are separated by half the total length. Closure under concatenation and union proves the complement claim. Select false statements B, C, D.

For the complement construction, Ea contains odd strings whose center is a and Eb those whose center is b. Concatenating lengths 2r+1 and 2s+1 puts their centers r+s+1 positions apart, exactly half the total length. Thus choosing unequal centers witnesses unequal half-positions. Conversely any mismatching pair in two equal halves determines such a split. Odd-length strings are automatically noncopies and form a regular language.

Original paper, page 32 · Answer key