GATE / CS ARCHIVE

GATE CSE 2017 SET 2 / QUESTION 40

GATE CSE 2017 Set 2 Q40

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

GATE 2017 Set 2, Q40 2 marks · MCQ
Report issue

Context-Free Grammars & Languages

Question 40, GATE 2017: L1={a^p | p prime}; L2={a^n b^m c^(2m) | n,m≥0}; L3={a^n b^n c^(2n) | n≥0}; L4={a^n b^n | n≥1}. Which claims hold? I:L1 is CFL but not regular. II:L2 is not CFL. III:L3 is not CFL but recursive. IV:L4 is deterministic CFL. A:I,II,IV. B:II,III. C:I,IV. D:III,IV.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

1. I is false. If L1 were context-free, choose a prime q above its pumping length. Any pumping decomposition increases the unary length by a positive d when pumped once extra. Pumping q extra copies gives length q+qd=q(1+d), a composite number, contradicting membership.

2. II is false: a CFG for L2 is S→aS|B and B→bBcc|ε. It independently generates any number of a symbols, then matches each b with two c symbols.

3. III is true. L3 is decidable by checking symbol order and counting the three runs. If it were CFL, inverse homomorphism under h(a)=a,h(b)=b,h(c)=cc would make {an bn cn} context-free, a contradiction to that standard non-CFL result. IV is true: a deterministic PDA pushes for a symbols, switches on the first b and pops for each b, accepting exactly matching positive counts. Therefore III and IV, D.

Original paper, page 15 · Answer key