Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

GATE | GATE-CS-2016 (Set 2) | Question 53

  • Last Updated : 01 Oct, 2021

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)


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

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

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 L2 cant be context free.

This solution is contributed by vineet purswani.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!