GATE | GATE-CS-2005 | Question 57

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?
(A) L1 is a deterministic CFL
(B) L2 is a deterministic CFL
(C) L3 is a CFL, but not a deterministic CFL
(D) L3 is a deterministic CFL


Answer: (B)

Explanation:  

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#w^R | 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 (0^n 1^n 0^n 1^n).
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{v^i}x{y^i}z belongs L3 for all i>=0.
There doesn’t exist any such configuration of u,v,w,x,y such that u{v^0}x{y^0}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.

Reference ;

https://courses.engr.illinois.edu/cs373/sp2013/Lectures/lec17.pdf

This solution is contributed by Vineet Purswani.

Quiz of this Question

My Personal Notes arrow_drop_up
Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.