Consider the CFG with {S, A, B} as the non-terminal alphabet, {a, b} as the terminal alphabet, S as the start symbol and the following set of production rules
S→bA
S→aB
A→a
B→b
A→aS
B→bS
A→bAA
B→aBB
Which of the following string is generated by the grammar?
A
aabbbb
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
abbbba
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
aabbab
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
D
aaaabb
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution
The correct option is C aabbab S⇒aB⇒aaBB⇒aabB⇒aabbS ⇒aabbaB⇒aabbab.