GATE / CS ARCHIVE

GATE CSE 2016 SET 2 / QUESTION 43

GATE CSE 2016 Set 2 Q43

Theory of Computation · Context-Free Grammars & Languages · Full GATE CSE 2016 Set 2 paper

GATE 2016 Set 2, Q43 2 marks · MCQ
Report issue

Context-Free Grammars & Languages

Question 43, GATE 2016: L1={a^n b^m c^(n+m):m,n≥1}; L2={a^n b^n c^(2n):n≥1}. A both context-free; B only L1; C only L2; D neither.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

L1 is generated by S→aSc|aBc and B→bBc|bc: each a or b adds one trailing c, with positive counts of both. Thus L1 is context-free. If L2 were context-free, its inverse image under h(a)=a, h(b)=b, h(c)=cc would be {an bn cn: n≥1}, which is not context-free by the pumping lemma. CFL closure under inverse homomorphism therefore proves L2 non-context-free. Answer B.

A pushdown intuition for L1 pushes one marker per a or b and pops one per c, with finite control enforcing the a-then-b-then-c phases. L2 must enforce three linked quantities. Under h(c)=cc, an input an bn cn maps exactly to an bn c2n, transferring the known non-CFL obstruction through inverse homomorphism.

Original paper, page 37 · Answer key