Discussion
Which of the following languages is generated by the given grammar?
\[ S \rightarrow aS \mid bS \mid \varepsilon \]
Answer: D
The grammar generates \(\{a,b\}^{*}\).
\(S \rightarrow aS \mid bS \mid \varepsilon\) lets each step add either an a or a b at the front and continue, or stop. Any string of a's and b's in any order, including the empty string, can be built letter by letter, so the language is all strings over \(\{a, b\}\).
\(\{a^{n}b^{m}\}\) forces all a's before the b's, but the grammar also gives ba. Nothing in the grammar counts letters, so the 'equal number' and \(a^{n}b^{n}\) options are far too narrow, and the grammar also produces strings like aab.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development