Tuesday 30 June 2015

Q35,p2,d14. The following Context-Free Grammar (CFG) :



S →aB | bA
A →a | as | bAA
B →b | bs | aBB
will generate
(A) odd numbers of a’s and odd numbers of b’s
(B) even numbers of a’s and even numbers of b’s
(C) equal numbers of a’s and b’s
(D) different numbers of a’s and b’s

Answer – All option are correct.

Explanation.
S->aB
S->bA
S->ab
S->abS
S->aBB
S->ba
S->baS
S->bbAA

S->abaB->abab
S->abb




Expand further al loptions.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.