Open In App

GATE | GATE-CS-2005 | Question 57

Last Updated : 28 Jun, 2021
Like Article

Consider the languages:

L1 = {wwR |w ∈ {0, 1}*}
L2 = {w#wR | w ∈ {0, 1}*}, where # is a special symbol
L3 = {ww |  w ∈  (0, 1}*)

Which one of the following is TRUE?


L1 is a deterministic CFL


L2 is a deterministic CFL


L3 is a CFL, but not a deterministic CFL


L3 is a deterministic CFL

Answer: (B)


L1: {ww^R | w belongs {0,1}*}
This is a CFL but not a DCFL. It can be derived from the following grammar
S -> aSa | bSb | epsilon
But it can’t be derived from any deterministic pushdown automaton, because there is no way to figure out where a word w ends and its reverse starts.

L2: {w#wR | w belongs {0,1}*}
This is a CFL, due to the same reason as described above. This is a deterministic CFL because we have a marker to help us find out the end of the word w and start of its reverse. Thus a PDA where all the alphabets are pushed until we get # and afterwards pop only if the top of the stack matches the current alphabet and reject otherwise – will derive L2.

L3: {ww | w belongs {0,1}*}
This is not even a CFL. Above claim could be proved using pumping lemma –
Consider a string z of the form (0n 1n 0n 1n).
Assuming L3 is a CFL, and z obviously satisfies L3 – thus z should also satisfy pumping lemma.
We will take n such that n = p, where p is the pumping length of L3, hence forcing our string to be of length greater than pumping length.
Now, according to pumping lemma, there must exist u,v,w,x,y such that z = uvwxy, |vwx| <= p, |vx| > 0 and u{vi}x{yi}z belongs L3 for all i>=0.
There doesn\’t exist any such configuration of u,v,w,x,y such that u{v0}x{y0}z belongs L3.
Hence z doesn\’t satisfy pumping lemma. 
Hence L3 is not a CFL. 

Considering all the above conclusions, only correct option comes out to be (B) L2 is a deterministic CFL. .

Quiz of this Question
Please comment below if you find anything wrong in the above post

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads