wiz-icon
MyQuestionIcon
MyQuestionIcon
1
You visited us 1 times! Enjoying our articles? Unlock Full Access!
Question

Consider the following context-free grammars:
G1:S aS | B,Bb | bB
G2:S aA | bB,AaA |B|ε,B bB|ε
Which one of the following pairs of languages is generatedby G1 and G2, respectively?

A
{ambn | m>0 and n>0}and{ambn | m>0 or n0}
No worries! We‘ve got your back. Try BYJU‘S free classes today!
B
{ambn | m0 and n>0}and{ambn | m>0 or n>0}
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
C
{ambn | m>0 or n>0}and{ambn | m>0 and n>0}
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
{ambn | m0 or n>0}and{ambn | m>0 and n>0}
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution

The correct option is B {ambn | m0 and n>0}and{ambn | m>0 or n>0}
G1:S aS | B
B b |bB
G2:S aA | bB
A aA |B | ε
B bB | ε
G: B b | bBBb+
Now substitute in S aS |B
We get S aS | b+Sab+
So, L(G1)={ambn | m0 and n>0}
G2=B bB | εBb
Substitute in A aA |B | εAaA | b | ε
A aA |b
A ab
Now substitute A and B in S aA |bB
S aab |bb
S aa b+bb
So, L(G2)={ambn |m>0 or n>0}
So correct answer is choice (d).


flag
Suggest Corrections
thumbs-up
0
Join BYJU'S Learning Program
similar_icon
Related Videos
thumbnail
lock
Construction of CFG Part - 2
OTHER
Watch in App
Join BYJU'S Learning Program
CrossIcon