GATE 2016 CS – Question 26
Which of the following languages is generated by the given grammar?
$S \rightarrow aS \mid bS \mid \epsilon$
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (D) $\{a, b\}^*$
Explanation
At each step the grammar can add either an $a$ or a $b$ in front, in any order, and then stop with $\epsilon$. So it generates every string over $\{a, b\}$, which is $\{a, b\}^*$.