GateAI
Regular and Context-Free Languages

GATE CSE 2017 Set 1 · Q38

MCQ2 marksEasy

Time

Consider the following languages over the alphabet Σ={a,b,c}\Sigma = \{a, b, c\}. Let L1={anbncm∣m,n≥0}L_1 = \{ a^n b^n c^m \mid m, n \ge 0 \} and L2={ambncn∣m,n≥0}L_2 = \{ a^m b^n c^n \mid m, n \ge 0 \}. Which of the following are context-free languages? I. L1∪L2L_1 \cup L_2 II. L1∩L2L_1 \cap L_2

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: A) I only

Regular and Context-Free Languages
  1. Context-freeness of L1L_1 and L2L_2:

    • L1={anbncm∣m,n≥0}L_1 = \{ a^n b^n c^m \mid m, n \ge 0 \} is context-free because a single pushdown automaton (PDA) can push aa's and pop them on matching bb's, then accept any number of cc's.

    • L2={ambncn∣m,n≥0}L_2 = \{ a^m b^n c^n \mid m, n \ge 0 \} is context-free because a PDA can skip any number of aa's, push bb's, and pop them on matching cc's.

  2. Statement I (L1∪L2L_1 \cup L_2):

    • Context-free languages are closed under union.

    • Since both L1L_1 and L2L_2 are CFLs, L1∪L2L_1 \cup L_2 is context-free.

  3. Statement II (L1∩L2L_1 \cap L_2):

    • L1∩L2={anbncn∣n≥0}L_1 \cap L_2 = \{ a^n b^n c^n \mid n \ge 0 \}, which is a standard non-context-free language (it requires two independent count comparisons, which a single stack cannot perform).

Therefore, only statement I is context-free, making (A) the correct choice.

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Regular and Context-Free Languages previous year question is Q38 of the GATE CSE 2017 Set 1 paper. Find more GATE CSE PYQs on Regular and Context-Free Languages in Theory of Computation, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Regular and Context-Free Languages PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Regular and Context-Free Languages in GATE CSE

Regular and Context-Free Languages has 21 GATE CSE PYQs across 13 papers from 2011 to 2026. 9 of them are 2-mark MCQs like this one, and it is the only one in GATE CSE 2017 Set 1.

How GATE tests Regular and Context-Free Languages

More from GATE CSE 2017 Set 1

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2017 Set 1 · Q38 · MCQ

Consider the following languages over the alphabet = {a, b, c}. Let L1 = { an bn cm m, n ≥ 0 } and L2 = { am bn cn m, n ≥ 0 }. Which of the following are context-free languages? I. L1 ∪ L2 II. L1 ∩ L2

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.