retagged by
24,771 views
48 48 votes

Identify the language generated by the following grammar, where $S$ is the start variable.

  • $ S \rightarrow XY$
  • $ X \rightarrow aX \mid a$
  • $ Y \rightarrow aYb \mid \epsilon$
  1. $\{a^mb^n \mid m \geq n, n > 0 \}$
  2. $ \{ a^mb^n \mid m \geq n, n \geq 0 \}$
  3. $\{a^mb^n \mid m >  n, n \geq 0 \}$
  4. $\{a^mb^n \mid m > n, n > 0 \}$

13 Answers

Best answer
46 46 votes

$S \to XY$

$X \to aX \mid a$

$Y \to aYb \mid \epsilon$


$X$ generates atleast one '$a$'. While $Y$ generates equal no of $a$'s and $b$'s( including epsilon).

$L = \{ a , aa, aaa, aab, aaaa, aaab,aaaaa, aaabb, \ldots\}$

Hence, answer should be Option C.

edited by
10 10 votes
Strings can be a,aa,aab,aaab.

A and B are not correct because no of a's can never be equal to no of b's in the given grammar.

so it would either be C or D.

but in D it is given n > 0 which is wrong because of Y -> $\varepsilon$

 

Ans is C
edited by
7 7 votes

X will gives a

y will give anbwhere n $\geq$ 0 

so language  is ap anb p >n and n $\geq$ 0 or  am b m >n and n $\geq$ 0 or  where m = p+n

Answer is C

3 3 votes
Option C-As number of B's can be zero and number of A's are greater  than number of B's.
1 1 vote
We can solve this question by options so

By observing options we can say that:-

$\large NOTE$: It is just a pseudocode don't relate it with programming

$\text{/*Number of a's strictly greater than b's*/} $
$if (m>n)\{$

            $\text{/*0 b's possible -(C)*/ }$
            $if(n==0) C$

            $\text{/*0 b's not possible -(D)*/}$
            $else\space D$

$\}$

$\text{/*Number of a's greater than b's*/} $
$if(m>=n)\{$

         $\text{/*0 b's possible B*/}$
         $if(n==0)  B$

        $\text{/*0 b's not possible A*/}$
        $else\space A$      

$\}$

$S\longrightarrow XY\longrightarrow X\longrightarrow a$

so we can't prove $\#a = \#b$ it means $(m=n)$

so option A and B eliminated and n is also 0 it means 0 b's also possible so option D eliminated

Hence $\large Option C$ is right answer
edited by
Answer:
Position:
Show:

Related questions

50 50 votes
6 answers 6 answers
14.8k
14.8k views
Madhav asked Feb 14, 2017
14,813 views
Consider the following languages.$L_1 = \{a^p \mid p \text{ is a prime number} \}$$L_2 = \{ a^nb^mc^{2m} \mid n \geq 0, m \geq 0 \}$$L_3 = \{a^n b^n c^{2n} \mid n \geq 0 ...
42 42 votes
5 answers 5 answers
14.1k
14.1k views
Madhav asked Feb 14, 2017
14,100 views
Let $L(R)$ be the language represented by regular expression $R$. Let $L(G)$ be the language generated by a context free grammar $G$. Let $L(M)$ be the language accepted ...
114 114 votes
13 answers 13 answers
46.1k
46.1k views
Arjun asked Feb 14, 2017
46,095 views
Let $\delta$ denote the transition function and $\widehat{\delta}$ denote the extended transition function of the $\epsilon$-NFA whose transition table is given below:$$\...
65 65 votes
10 answers 10 answers
28.2k
28.2k views
Madhav asked Feb 14, 2017
28,150 views
The minimum possible number of states of a deterministic finite automaton that accepts the regular language $L$ = {$w_{1}aw_{2}$ | $w_{1},w_{2}$ $\in$ $\left \{ a,b \righ...