Skip to content
Related Articles
Open in App
Not now

Related Articles

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

Improve Article
Save Article
  • Last Updated : 01 Oct, 2021
Improve Article
Save Article

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

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
Related Articles

Start Your Coding Journey Now!