in Theory of Computation edited by
26,675 views
59 votes
59 votes

Consider the following context-free grammars;

$G_1 : S \to aS \mid B, B \to b \mid bB$

$G_2 : S \to aA \mid bB, A \to aA \mid B \mid \varepsilon,B \to bB \mid \varepsilon$

Which one of the following pairs of languages is generated by $G_1$ and $G_2$ ,respectively?

  1.  $\{ a^mb^n \mid m > 0 \text{ or } n >0\}$ and $\{ a^mb^n \mid m > 0 \text{ and } n >0\}$ 
  2.  $\{ a^mb^n \mid m > 0 \text{ and } n >0\}$ and $\{ a^mb^n \mid m > 0 \text{ or } n\geq0\}$
  3.  $\{ a^mb^n \mid m \geq 0 \text{ or } n >0\}$ and $\{ a^mb^n \mid m > 0\text{ and } n>0\}$
  4.  $\{ a^mb^n \mid m \geq 0 \text{ and } n >0\}$ and $\{ a^mb^n \mid m > 0 \text{ or } n>0\}$
in Theory of Computation edited by
26.7k views

4 Comments

C and D options are exactly similar 🤔
1
1

how option C is wrong expain with contradictory example ?

0
0
edited by
$ \{ a^mb^n \mid m \geq 0 \text{ and } n >0\}$ and$ \{ a^mb^n \mid m > 0 \text{ or } n>0\}$

can we can write option D as below ?

$ \{ a^mb^n \mid m \geq 0 \text{ and } n >0\}$ and$ \{ a^mb^n \mid m \geq 0 \text{  and } n \geq0\} $
0
0

8 Answers

85 votes
85 votes
Best answer

Answer is (D).

$G_1$ results in strings $b, ab, bb, aab, abb, bbb,$ ... i.e $a^mb^n$, $m\geq 0$ and $n > 0$ (and because only $a$'s are not possible but only $b$'s are)

$G_2$ result in strings $a, b, aa, ab, bb, aaa, aab, abb, bbb$   ... i.e $a^mb^n$, $m > 0$ or $n > 0$ (or because only $b$'s is possible $b,bb,bbb,$ , only $a$'s are possible)

selected by

4 Comments

D is the correct answer. For G1, ‘b’ occurs atleast once.
0
0

in G2 language why they are not used greater than or equal to bcoz here m or n can also be equal to zero ?

0
0
Anyone please explain what is wrong when we choose option C as answer

i am confused that the how AND  and OR  creates difference here?
0
0
41 votes
41 votes

if we have given  right linear grammar,,,then it  is better to draw FA and then analyze the language

and we know null production corrresponds to final state and unit production corresponds to null moves  

now it is clear that

L1 = a* b*b = a*b+    {ambn , m>=0 and  n>0}

and 

L2 = aa* + bb* +  ab+ = a+ + b+  ab+     =  {ambn , m>0 or  n>0}

4 Comments

@Kushagra गुप्ता

You can't write RE for the given Grammar coz it's not either RLG or LLG or Type-3 Grammar.

0
0

@ayushsomani

It is extended right linear grammar. So we can write RE for it.

0
0
0
0
9 votes
9 votes
my ans is D.

beacuse in G1, a may be 0 or more... but we have to generate b.. "and" will be used in side g1.. not "or"

only option D consist it..no need to check G2 then.

plz correct me if wrong
1 vote
1 vote

(D) is correct..No need to check for G2, bcoz clarfying G1 there is no matching in 1st phase in any other option.

Answer:

Related questions