StreakPeaked· Practice

ExamsGATETechnical

Which of the following languages is generated by the given grammar? S → aS | bS | ε

  1. {aⁿ b^m | n,m ≥ 0}
  2. {w ∈ {a,b}* | w has equal number of a’s and b’s}
  3. {aⁿ | n ≥ 0} ∪ {bⁿ | n ≥ 0} ∪ {aⁿ bⁿ | n ≥ 0}
  4. {a,b}*

Correct answer: {a,b}*

Solution

The grammar allows for any combination of 'a' and 'b' by recursively adding 'a' or 'b' to the string, including the empty string, which means it can generate all possible strings made up of 'a' and 'b'.

Related GATE Technical questions

⚔️ Practice GATE Technical free + battle 1v1 →