• retagged by
1,913 views
2 2 votes

Let $L_{1}:=\{a^{n}b^{m}\mid m,n\geq 0\: \text{and}\: m\geq n\}$ and  $L_{2}:=\{a^{n}b^{m}\mid m,n\geq 0\: \text{and}\: m < n\}.$
The language $L_{1}\cup L_{2}$ is:

  1. regular, but not context-free
  2. context-free, but not regular
  3. both regular and context-free
  4. neither regular nor context-free

3 Answers

4 4 votes

$L_1$ contains set of all strings of the form $(a...b...)$ where number of $b'$s should be greater than or equal to $a'$s

i.e. $L_1 = \{ \epsilon , b ,bb, bbb...., ab, abb , abbb, .....,aabb, aabbb..... \}$


$L_2$ contains set of all strings of the form $(a...b...)$ where number of $b'$s should be strictly less than $a'$s

i.e. $L_2 = \{  a ,aa, aaa...., aab, aaab, aaabb , aaaab, aaaabb, aaaaabbb, .....\}$

 
So when we do union of both $L_1$ and $L_2$ then we will get a language in which

Either (number of $b'$s should be greater than or equal to $a'$s) OR (number of $b'$s should be strictly less than $a'$s)

i.e. $L_1 \cup L_2 = \{ a^nb^m | n,m \geq 0\ and\ m \geq n \ OR\ m < n \} $

i.e. We can have any number of $a's$ followed by any number of $b'$s

i.e. $ L_1 \cup L_2= \{ a^nb^m | n , m \geq 0 \}$



 This is a regular language since we can draw a finite automata for it.

And as we know every regular language is also a context free language .

$\therefore$ Option $C.$ is the correct answer.

• edited by
0 0 votes
This question is one of the good examples of knowing where not to apply closure property to get the answer.

 Both are DCFL, since DCFLs are not closed under union operations, so let’s upgrade it to CFL and since CFL are in fact closed under union operation, we stop and say the result must be a CFL.  And a CFL need not be regular,so it seems option B is right but here we need to be careful, since it is MCQ, we have to be very cautious while choosing an option.

When we do actual union of the language, we will see it generates a*b* which is in fact regular, and a regular is always a CFL,so option C is right
Answer:
Position:
Show:

Related questions

3 3 votes
3 answers 3 answers
2.4k
2.4k views
gatecse asked Sep 13, 2019
2,434 views
Consider an alphabet $\Sigma=\{a,b\}.$Let $L_{1}$ be the language given by the regular expression $(a+b)^{\ast}bb(a+b)^{\ast}$ and let $L_{2}$ be the language $baa^{\ast}...
1 1 vote
2 2 answers
1.5k
1.5k views
gatecse asked Sep 13, 2019
1,527 views
Let $A$ be an $NFA$ with $n$ states. Which of the following is necessarily true?The shortest word in $L(A)$ has length at most $n-1.$The shortest word in $L(A)$ has lengt...
0 0 votes
2 2 answers
1.1k
1.1k views
gatecse asked Sep 13, 2019
1,111 views
We have constructed a polynomial time reduction from problem A to problem B. Which of the following is not a possible scenario?We know of polynomial time algorithms for b...
6 6 votes
4 4 answers
3.6k
3.6k views
gatecse asked Sep 13, 2019
3,604 views
Suppose that the figure to the right is a binary search tree. The letters indicate the names of the nodes, not the values that are stored. What is the predecessor node, i...