The GATE Grind

GATE 2016 CS (CS2) – Question 53

Theory of Computation · Regular and Context-Free Languages, Pumping Lemma · 2 marks · Multiple choice

$L_1=\{a^nb^mc^{n+m}:m,n\ge1\}$ and $L_2=\{a^nb^nc^{2n}:n\ge1\}$. Which holds?

  1. Both are context-free
  2. L₁ is context-free; L₂ is not
  3. L₂ is context-free; L₁ is not
  4. Neither is context-free

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (B) L₁ is context-free; L₂ is not

Explanation

A PDA for L₁ pushes once per a or b and pops once per c, also checking positive a and b blocks, so L₁ is context-free. If L₂ were context-free, its inverse homomorphism under h(a)=a,h(b)=b,h(c)=cc would make {aⁿbⁿcⁿ:n≥1} context-free, a contradiction. Thus B.

More Regular and Context-Free Languages, Pumping Lemma questions

All Regular and Context-Free Languages, Pumping Lemma questions →