Skip to content
Related Articles

Related Articles

GATE | GATE-CS-2016 (Set 2) | Question 53
  • Last Updated : 13 Feb, 2016

Consider the following languages:
L1 = {anbmcn : m, n >= 1}
L2 = {anbnc2n : n >= 1}
Which one of the following is TRUE?
(A) Both L1 and L2 are context-free.
(B) L1 is context-free while L2 is not context-free.
(C) L2 is context-free while L1 is not context-free.
(D) Neither L1 nor L2 is context-free.


Answer: (B)

Explanation:  

L1 = {anbmcn |m, n ≥ 1} is context free language because it is derived by the following CFG:
S− > aSc|aBc;
B− > bB|b

L2 = {anbnc2n |n ≥ 1} is not a context free language, this can be proved using pumping lemma. Intuitively, a pushdown automaton can’t remember number of as for the third set of characters coming, i.e. c. This language is very similar to {anbncn |n ≥ 1} which is known to be a non-CFL.

Hence, correct answer would be (B) L1 is context-free while L2 is not context-free.

L2 is not context free. no. of b’s will match with no. of a’s leaving c’s to be matched with no one..so L2 cant be context free.

This solution is contributed by vineet purswani.

Quiz of this Question

sudo-gate-course

My Personal Notes arrow_drop_up
Recommended Articles
Page :