S1: The grammars S ->asb | bsa | ss | a and S ->asb |
bsa | a are not equivalent.
S2: The grammars S ->ss | sss | asb | bsa | λ and S ->ss | asb | bsa | λ are equivalent.
Which of the following is true ?
(A) S1
is correct and S2 is not correct.
(B) Both S1and S2
are correct.
(C) S1is not correct and S2
is correct.
(D) Both S1 and S2
are not correct.
Answer B.
Explanation.
One length word generated by G1 in
statement 1 . {a}.
One length word generated by G2 in
statement 1. {a}.
Two word length generated by G1 in
statement 1. {aa}.
Two word length generated by G2 in
statement 1.{}.
Hence we can say that two grammars
are not equivalents.
Two length word generated by G3, G4 in statement s2. {ab,ba}.
Four length word generated by G3.
The grammars S ->ss | sss | asb |
bsa | λ
S->ss->abab
S->ss->abba
s->ss->baab
s->ss->baba.
s->sss->abab,baab,baba,abba.
s->asb->aabb.
s->asb->abab
s->bsa->baba
s->bsa->bbaa
Four length words generated by G4
S ->ss | asb | bsa | λ are same as above.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.