Exams › GATE › Technical
Consider the following context-free grammar G, where S, A, and B are the variables (non-terminals), a and b are the terminal symbols, S is the start variable, and the rules of G are described as:
S → aaB | Abb
A → a | aA
B → b | bB
Which ONE of the languages L(G) is accepted by G?
- L(G) = {a² bⁿ | n ≥ 1} ∪ {aⁿ b² | n ≥ 1}
- L(G) = {aⁿ b² n | n ≥ 1} ∪ {a² n bⁿ | n ≥ 1}
- L(G) = {aⁿ bⁿ | n ≥ 1}
- L(G) = {a² n b² n | n ≥ 1}
Correct answer: L(G) = {a² bⁿ | n ≥ 1} ∪ {aⁿ b² | n ≥ 1}
Solution
The correct option describes the language generated by the grammar, where the productions allow for the generation of strings with two 'a's followed by one or more 'b's, or any number of 'a's followed by exactly two 'b's, thus matching the specified patterns.
Related GATE Technical questions
⚔️ Practice GATE Technical free + battle 1v1 →