Theory Of Computation MCQ

1:

Following context free grammar
S —> aB | bA 
A —>b | aS | bAA
B —> b | bS | aBB 

generates strings of terminals that have

A. equal number of a's and b's
B. odd number of a's and odd number b's
C. even number of a's and even number of b's
D. odd number of a's and even number of a's
 

Answer : A

Explanation :
S —> aB —> aaBB-->aabB —> aabb
So (b) is wrong. We have
S --> a B —> a b So (c) is wrong.
A careful observation of the productions will
reveal a similarity. Change A to B, B to A, a to b
and b to a. The new set of productions will be
the same as the original set. So (d) is false and
(a) is the correct answer.

manjureka said: (2:12pm on Friday 12th June 2015)
Option A also wrong..why because the string aB>abs>abbA>abbbAA>abbbbb it may confuse please give me the clear solution for me.....
TJ said: (5:48pm on Wednesday 7th October 2015)
the given answer is incorrect. and for the above answer A, grammer must be A->a|aS|bAA and for S and B same as above. then it will work.
anubhav said: (1:37am on Thursday 30th June 2016)
option A is wrong as this grammar is accepting "bb" in which no. of a's and b's are not equal...
mozhi said: (4:33pm on Thursday 4th May 2017)
Suppose we derive llike S —> bA

Write your comments here:


Report Error
 

Option: A

Explanation : Explanation will come here. Explanation will come here. Explanation will come here. Explanation will come here. Explanation will come here.