GATE 2023 CS – Question 39
Consider the context-free grammar G below: S → aSb | X; X → aX | Xb | a | b, where S and X are non-terminals, and a and b are terminal symbols. The starting non-terminal is S. Which one of the following statements is CORRECT?
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (B) The language generated by G is $a^*(a+b)b^*$
Explanation
X generates a*(a+b)b*. S wraps X as a^n X b^n, which still gives strings of the form a*(a+b)b*. So L = a*(a+b)b*, which is regular.