GATE / CS ARCHIVE

GATE CSE 2016 SET 2 / QUESTION 17

GATE CSE 2016 Set 2 Q17

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

GATE 2016 Set 2, Q17 1 mark · MCQ
Report issue

Context-Free Grammars & Languages

Question 17, GATE 2016: L1 has grammar S1→aS1b|ε, and L2 has S2→abS2|ε. P: L1 is regular; Q: L2 is regular. A both; B P only; C Q only; D neither.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

L1={an bn: n≥0}, nonregular by pumping/distinguishable prefixes. L2=(ab)* is regular. Therefore P false, Q true, C.

Each use of S1→aS1b adds one a and one b at opposite ends; ε stops the derivation. Pumping an a-prefix of ap bp changes only the a count, proving nonregularity. In contrast, S2 repeatedly appends the fixed block ab; a three-state complete DFA can check alternating a,b blocks and reject violations.

Original paper, page 29 · Answer key