Skip to content
Related Articles

Related Articles

GATE | GATE CS 2021 | Set 2 | Question 51

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 23 May, 2021

For a string w, we define wR to be the reverse of w. For example, if w = 01101 then wR = 10110.

Which of the following languages is/are context-free?
(A) {wxwRxR ∣ w,x∈{0,1}*}
(B) {wwRxxR ∣ w,x∈{0,1}*}
(C) {wxwR ∣ w,x∈{0,1}*}
(D) {wxxRwR ∣ w,x∈{0,1}*}


Answer: (B) (C) (D)

Explanation: Option A: L={w x w^R x^R | w, x ∈ {0,1}* }
This is not CFL as if we push “w” then “x” then we cannot match w^R with “w” as top of stack contains x.

Option B: L={w w^R x x^R | w, x ∈ {0,1}* }
This is CFL. We non deterministically guess the middle of the string. So we push “w” then match with w^R and again push x and match with x^R

Option C: L={w x x^R w^R | w, x ∈ {0,1}* }
This is also CFL. We non deterministically guess the middle of the string. So we push “w” then push x and then match with x^R and again match with w^R

Option D: L={w x w^R | w, x ∈ {0,1}* }
This is a regular language (hence CFL). In this language every string start and end with same symbol (as x can expand).

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!