Consider the following grammar: S→XY X→YaY | a and Y→bbX Which of the following statements is/are true…
Since Y → bbX, the rule S → XY gives S → XbbX, and each X yields at least one a, so every string has at least two a's: (c) is true. The letter b appears only through Y, two…
Choose your answer
Consider the following grammar:
S→XY
X→YaY | a and Y→bbX
Which of the following statements is/are true about the above grammar?
(a) Strings produced by the grammar can have consecutive three a’s.
(b) Every string produced by the grammar have alternate a and b.
(c) Every string produced by the grammar have at least two a’s.
(d) Every string produced by the grammar have b’s in multiple of 2.
Answer and explanation
Correct answer D
Since Y → bbX, the rule S → XY gives S → XbbX, and each X yields at least one a, so every string has at least two a's: (c) is true. The letter b appears only through Y, two at a time, so the number of b's is always even: (d) is true. (b) fails because bb occurs in every string, and (a) fails because each X starts either with bb or as the single a and always ends in one a, so at most two a's ever stand together.
Practice for these exams
-
UGC NET Computer Science and Applications