Tuesday, 12 May 2015

Q39,paper 3,j 12.The following CFG


S→aB | bA,
A →a | as | bAA,
B →b | bs | aBB
generates strings of terminals that have Options (A) odd number of a’s and odd number of b’s
(B) even number of a’s and even number of b’s
(C) equal number of a’s and b’s
(D) not equal number of a’s and b’s
Answer© equal number of a’s and b’s.
Explanation
String of length 1.={}
String of length 2. S->aB, S->ab.
Or
s->bA,S->ba.
So it is {ab,ba}
String of length 3.{}.
String of length 4.
S->bA,
S->bbAA,
S->bbaa
Or S->aB
S->aaBB
S->aaBB.
={aabb,bbaa}.
Hence it can be generalized as equal number of a’s and b’s.

No comments:

Post a Comment

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