332 views

Consider the context-free grammar below ($\epsilon$ denotes the empty string, alphabet is $\{a,b\}$):

$$S\rightarrow \epsilon \mid aSb \mid bSa \mid SS.$$

What language does it generate?

1. $(ab)^{\ast} + (ba)^{\ast}$
2. $(abba) {\ast} + (baab)^{\ast}$
3. $(aabb)^{\ast} + (bbaa)^{\ast}$
4. Strings of the form $a^{n}b^{n}$ or $b^{n}a^{n},n$ any positive integer
5. Strings with equal numbers of $a$ and $b$

### 1 comment

The question is revealing the answer. The pdf given by tifr is editable. Just click on tick sign, it will get selected and then you can delete it (i had done it on prev yrs papers on my mac). Removing the bold is bigger problem -- that will probably need paid version of adobe acrobat reader. In case you have that then bold can be removed as well.

Other option is manually typing it in Tex.

$S\rightarrow \epsilon \mid aSb \mid bSa \mid SS$

• $S\rightarrow a\underline{S}b$
• $S\rightarrow a\underline{S}Sb$
• $S\rightarrow a a\underline{S}b Sb$
• $S\rightarrow a ab\underline{S}a b Sb$
• $S\rightarrow a aba b \underline{S}b$
• $S\rightarrow a aba b b$

Stings with an equal number of $a's$ and $b's.$

References:

So, the correct answer is $(E).$