reopened by
8,700 views
2 votes
2 votes

The following Context-Free Grammar (CFG) :

$S \rightarrow aB | bA$

$A \rightarrow a | as | bAA$

$B \rightarrow b | bs | aBB$ 

will generate

  1. Odd numbers of $a's$ and odd numbers of $b's$
  2. Even numbers of $a's$ and even numbers of $b's$ 
  3. Equal numbers of $a's$ and $b's$
  4. Different numbers of $a's$ and $b's$ 
reopened by

6 Answers

7 votes
7 votes

Answer : A

How answer A is True ?

If you consider this CFG you can definitely generate odd no of a's and odd no of b's no one going to stop you but the real question can you generate all the strings out of this grammar which are having odd no of a's and odd no of b's Answer is no you can't generate.

Consider option B : The string in which you have abbb (odd no of a's and odd no of b's ).This string can't be generate by this grammar you can try it .We only consider the Language if it is able to generate all the possible strings of that type .

Consider the option C : here again you can generate the strings having odd no of a's and even no of b's but you can't generate all .One of the string which you can't generate is " a" (Here we have 1-a and 0 no of b's) .

consider the option D  :here again we are able to generate some of the string which are having even no of a's and even no of b's .But not all Here is the Exp : we can't generate epsilon in which we have even no of a's and even no of b's .

Finally Consider option A in this you can generate all possible string out of this grammar in which you are going to have equal no of a's and equal no of b's .

That's why option A is correct .

1 flag:
✌ Edit necessary (simeonsg “Option C is correct, not A”)
5 votes
5 votes

Option A) would be the correct answer.

Because we can generate the string aabb (Which is a contradiction to Option B and C).

Given CFL also can generate ab (Which is contradiction to the option D). 

1 votes
1 votes
Answer C: Equal number of a's and b's

Option A is false because we can get even number of a's and even number of b's.

Example1: S -> bA -> bbAA -> bbaA -> bbaa

option B is false because we can get odd number of a's and odd number of b's.

Example2: S -> aB -> ab

The above two examples are creating equal number of a's and b's. This makes option D false
edited by
Answer:

Related questions

2 votes
2 votes
1 answer
1
makhdoom ghaya asked Jul 24, 2016
1,602 views
Match the following $:$ $\begin{array}{clcl} & \textbf{List – I} && \textbf{List – II} \\ \text{a.} & \text{Call Control protocol} &\text{i.} & \text{Interface b...
0 votes
0 votes
1 answer
2
makhdoom ghaya asked Jul 23, 2016
1,160 views
________ model is designed to bring prices down by increasing the number of customers who buy a particular product at once.Economic Order QuantityInventory Data MiningDem...
0 votes
0 votes
3 answers
3
makhdoom ghaya asked Jul 23, 2016
3,371 views
Which e-business model allows consumers to name their own price for products and services ? $B2 B$$B2 G$ $C2 C$ $C2 B$
1 votes
1 votes
1 answer
4
makhdoom ghaya asked Jul 23, 2016
2,401 views
Fact-less fact table in a data warehouse containsOnly measuresOnly dimensionsKeys and measuresOnly surrogate keys