GATE / CS ARCHIVE

GATE CSE 2017 SET 1 / QUESTION 38

GATE CSE 2017 Set 1 Q38

Theory of Computation · Closure Properties & Language Hierarchy · Full GATE CSE 2017 Set 1 paper

GATE 2017 Set 1, Q38 2 marks · MCQ
Report issue

Closure Properties & Language Hierarchy

Question 38, GATE 2017: L1={a^n b^n c^m:m,n≥0}, L2={a^m b^n c^n:m,n≥0}. Which are context-free? I L1∪L2; II L1∩L2. A I only; B II only; C both; D neither.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

1. L1 is context-free: a stack can match a’s with b’s and then ignore a trailing c block. L2 is likewise context-free by ignoring the initial a block and matching b’s with c’s.

2. Context-free languages are closed under union: a new start symbol can choose either constituent grammar. Therefore I holds.

3. Intersection forces #a=#b=#c and preserves block order, giving {an bn cn}. For pumping length p, a pump window of length at most p in ap bp cp touches at most two blocks. Pumping changes some count but leaves a third unchanged, or breaks the block order. Thus it is not context-free; answer A.

Original paper, page 17 · Answer key