GATE / CS ARCHIVE

GATE CSE 2015 SET 3 / QUESTION 44

GATE CSE 2015 Set 3 Q44

Theory of Computation · Context-Free Grammars & Languages · Full GATE CSE 2015 Set 3 paper

GATE 2015 Set 3, Q44 2 marks · MCQ
Report issue

Context-Free Grammars & Languages

Question 44, GATE 2015: Which languages are context-free? L1={a^m b^n a^n b^m | m,n≥1}; L2={a^m b^n a^m b^n | m,n≥1}; L3={a^m b^n | m=2n+1}. Exponents denote nonnegative integer counts unless constrained otherwise. Options: (A) L1 and L2 only; (B) L1 and L3 only; (C) L2 and L3 only; (D) L3 only.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

1. L1=am bn an bm has nested dependencies: S→aSb|aTb and T→bTa|ba generates m, n≥1, so it is CFL.

2. L3 is generated by U→aaUb|a for n≥0. L2=am bn am bn is not CFL: for pumping length p, choose ap bp ap bp. The pumping window of length≤p touches at most two adjacent blocks, so pumping changes at least one block but cannot change its corresponding nonadjacent equal block; if a pumped piece crosses a boundary, pumping can also destroy the four-block form. Thus pumping fails. L1, L3 only, B.

Original paper, page 68 · Answer key