edited by
3,548 views
2 votes
2 votes

Given the following two languages:

  • $L_1=\{a^nba^n\;|\;n>0\}$
  • $L_2=\{a^nba^nb^{n+1}\;|\;n>0\}$

Which of the following is correct?

  1.  $L_1$ is context free language and $L_2$ is not context free language
  2.  $L_1$ is not context free language and $L_2$ is context free language
  3.  Both $L_1$ and $L_2$ are context free languages
  4.  Both $L_1$ and $L_2$ are not context free languages
edited by

3 Answers

Best answer
7 votes
7 votes
Answer : A

A. L1 is context free language (deterministic) and L2 is not context free language

For L1, we need to count the number of a's before and after 'b' and this length is not finite. Hence, it is DCFL and not regular.

For L2, in addition to above comparison, we also need to ensure number of b's following the a's is just one more. This is a second non-finite comparison and cannot be done with just one stack. So, this makes L2 a CSL.
edited by
3 votes
3 votes
$L_1=\{a^nba^n\;|\; n>0\}$ is CFL

push $a's$ in stack ,do nothing with $b$ , then pop $a's$ from stack on reading $a's$

$L_2=\{a^nba^nb^{n+1}\;|\; n>0\}$ is CSL.

Push $a's$ in stack, donothing on $b$ , pop $a's$ from stack on reading $a's$, then we left with $b's$ with empty stack, then we can't ensure these $b's$ are one more that earlier $a's$.

Option $A$, $L_1$ is context free and $L_2$ is not context free language.
0 votes
0 votes

l1 :is language for which we cant write regular expression and it need stack  for comparison  so it is CFL
l2 eg: a^3ba^3b^4
first push all three a's in stack than when b comes pop all upconing a's with those a's which are present in stack ..now at this point one comparison is over..now 4 b''ss comes neglect them or we can say do thing with them so we left with empty stack so it is also CFL..
so (c) option 

Answer:

Related questions

3.1k
views
1 answers
4 votes
go_editor asked Aug 9, 2016
3,113 views
Match the following $:$$\begin{array}{clcl} & \textbf{List – I} & & \textbf{List – II} \\ \text{(a)} & \{a^n b^n \mid n 0\} \text{ is a deterministic } & \text{...
2.1k
views
2 answers
2 votes
go_editor asked Aug 9, 2016
2,107 views
The family of context sensitive languages is _____ under union and ____ under reversalclosed, not closednot closed, not closedclosed, closednot closed, closed
2.6k
views
5 answers
6 votes
Sankaranarayanan P.N asked Aug 2, 2016
2,646 views
Consider Language $A$ defined over the alphabet $\Sigma=\{0,1\}$ as $A=\{0^{\lfloor n/2 \rfloor} 1^n :n>=0 \}$ The expression $\lfloor n/2 \rfloor$ means the floor of $n/...
3.2k
views
1 answers
2 votes
shekhar chauhan asked Jun 5, 2016
3,176 views
The context free grammar given by$S \rightarrow XYX$$X \rightarrow aX \mid bX \mid \lambda$$Y \rightarrow bbb$generates the language which is defined by regular expressio...
Total PHP MySQL Other RAM
Time (ms) % Time (ms) % File count Time (ms) % Query count Time (ms) % Amount %
Setup 4.3 4% 2.7 2% 72 1.5 1% 2 0.0 0% 569k 44%
Control 13.3 12% 1.9 1% 5 11.8 11% 12 0.0 0% 258k 20%
View 2.0 1% 2.0 1% 12 0.0 0% 0 0.0 0% 134k 10%
Theme 80.6 76% 4.7 4% 15 76.0 72% 3 0.0 0% 312k 24%
Stats 4.6 4% 0.1 0% 0 4.5 4% 1 0.0 0% 0k 0%
Total 104.7 100% 11.4 10% 104 93.9 89% 18 0.0 0% 1276k 100%