GATE / CS ARCHIVE

GATE CSE 2017 SET 2 / QUESTION 16

GATE CSE 2017 Set 2 Q16

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

GATE 2017 Set 2, Q16 1 mark · MCQ
Report issue

Context-Free Grammars & Languages

Question 16, GATE 2017: Start variable S has grammar S→XY, X→aX|a, Y→aYb|ε. Which language is generated? A:{a^m b^n | m≥n,n>0}. B:{a^m b^n | m≥n,n≥0}. C:{a^m b^n | m>n,n≥0}. D:{a^m b^n | m>n,n>0}.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

1. X contributes at least one a: using aX k-1 times and then a gives ak for every k≥1. It cannot derive ε.

2. Y contributes matched numbers of a and b. Applying aYb n times and then ε gives an bn for every n≥0. Therefore XY yields ak+nbn, so m=k+n>n and n may be zero.

3. Conversely, if m>n≥0, choose k=m-n≥1 in X and n matching pairs in Y to derive the desired string. The characterization is exact, C. For example a is generated, ruling out options requiring n>0; equal counts are impossible because X supplies extra a symbols.

Original paper, page 7 · Answer key