The following Context-Free Grammar (CFG):
S → aB | bA
A → a | aS | bAA
B → b | bS | aBB
may generates(s)
A
Different numbers of a's and b's.
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
At least one odd numbers of a's and odd numbers of b's
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
C
Equal numbers of a's and b's
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
D
Even numbers of a's and even number of b's
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
Open in App
Solution
The correct option is D Even numbers of a's and even number of b's Option (a,b,c)
The following Context-Free Grammar (CFG):
S → aB | bA
A → a | aS | bAA
B → b | bS | aBB
will generate
Odd numbers of a's and odd numbers of b's i.e. al
Even numbers of a's and even numbers of b's i.e. e
Equal numbrs of a's' and b's i.e. ab, ba, bbaa or aal
It will not generate different numbers of a's and b'