GATE | GATE CS 2019 | Question 40

Which one of the following languages over ∑ = {a, b} is NOT context-free?
(A) {anbi ⏐ i ∈ {n, 3n, 5n}, n≥ 0}
(B) {wanwRbn ⏐ w ∈ {a, b}*, n≥ 0}
(C) {wwR ⏐ w ∈ {a, b}*}
(D) {wan bn wR ⏐ w ∈ {a, b}*, n≥ 0}


Answer: (B)

Explanation: (A): It is CFL, because we have union of three CFLs, and CFLs are closed under union property.

{anbi ⏐ i ∈ {n, 3n, 5n}, n≥ 0} 
= anbn ∪ anb3n ∪ anb5n 

We can identify strings of these language using only one stack.

(B): It is not CFL, because you can identify strings of given langauge using only one stack, you need atleast 2 stacks. There is alternate string matching which is not possible using only one stack. It is context sensitive language but not content free.

(C): It is very well known CFL. It is language of palindrome over only two alphabets which can be recognize by using only one stack.

(D): It is also CFL, since we can first push w, then a’s, b’s pop with a’s and wR pops with the w. So PDA can accept the language.

Option (B) is correct.

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.