446 views
8 votes
8 votes
Mark all the context-free languages given below
  1. $L = \{x\#w \mid x,w \in \Sigma^* \text{ and } x \text{ is a substring of } w\}$
  2. $L=\{a^nb^{n+m}c^md^{n}\mid n,m \geq 0\}$
  3. $L = \{1^n \mid n\text{ is a power of }2\}$
  4. $L = \{0^n1^m0^m1^n\mid m,n \geq 0\}$

1 Answer

Best answer
4 votes
4 votes
A is not context-free as this requires string comparison and thus an LBA.

B is not context free as we cant design a PDA here. We can solve it easily by putting $m=0$ and we get $a^nb^nc^n$ which is a well known non CFL.

C is not context-free as checking for a power of $2$ is above the limits of a PDA.

D is context-free as we can Push n 0's, followed by m 1's. Now, when 0 comes, we start popping and continue  when 1 comes (when 1 comes stack must pop 1 and not 0) also. We accept on stack being empty.

So, correct option is D.
selected by
Answer:

Related questions