Given the following productions of a grammar: S → aA | aBB A → aaA | λ B → bB…
2013
Given the following productions of a grammar:
S → aA | aBB
A → aaA | λ
B → bB | bbC
C → B
Which of the following is true?
- A.
The language corresponding to the given grammar is a set of even number of a’s
- B.
The language corresponding to the given grammar is a set of odd number of a’s
- C.
The language corresponding to the given grammar is a set of even number of a’s followed by odd number of b’s
- D.
The language corresponding to the given grammar is a set of odd number of a’s followed by even number of b’s
Attempted by 29 students.
Show answer & explanation
Correct answer: B
The production S → aA generates strings starting with 'a' followed by pairs of 'a's from A, resulting in an odd total count of 'a's. The alternative path S → aBB involves non-terminals B and C that recurse indefinitely without a base case, generating no valid terminal strings. Therefore, the language consists solely of strings with an odd number of 'a's.
A video solution is available for this question — log in and enroll to watch it.