GateAI
Regular and Context-Free Languages

GATE CSE 2021 Set 2 · Q12

MSQ1 markMedium

Time

Let L1L_1 be a regular language and L2L_2 be a context-free language. Which of the following languages is/are context-free?

Select all that applyOne or more correct

Pick every correct option

Solution

Step-by-step verified solution

Official answer: B) L1 ∪ L2; C) L1 ∪ (L2 ∪ L2); D) (L1 ∩ L2) ∪ ( L1 ∩ L2)

Regular and Context-Free Languages

Let us analyze each option using set theory and closure properties of context-free languages (CFLs):

  • Option (A): L1∩L2‾L_1 \cap \overline{L_2} CFLs are not closed under complementation, so L2‾\overline{L_2} may not be a CFL or even recursive. Thus, the intersection of a regular language and the complement of a CFL is not necessarily context-free.

  • Option (B): L1‾∪L2‾‾\overline{\overline{L_1} \cup \overline{L_2}} By De Morgan's laws:

    L1‾∪L2‾‾=L1‾‾∩L2‾‾=L1∩L2\overline{\overline{L_1} \cup \overline{L_2}} = \overline{\overline{L_1}} \cap \overline{\overline{L_2}} = L_1 \cap L_2

    The intersection of a regular language (L1L_1) and a context-free language (L2L_2) is always context-free. Thus, (B) is a CFL.

  • Option (C): L1∪(L2∪L2‾)L_1 \cup (L_2 \cup \overline{L_2}) Since L2∪L2‾=Σ∗L_2 \cup \overline{L_2} = \Sigma^*:

    L1∪(L2∪L2‾)=L1∪Σ∗=Σ∗L_1 \cup (L_2 \cup \overline{L_2}) = L_1 \cup \Sigma^* = \Sigma^*

    Σ∗\Sigma^* is a regular language, and every regular language is also context-free. Thus, (C) is a CFL.

  • Option (D): (L1∩L2)∪(L1‾∩L2)(L_1 \cap L_2) \cup (\overline{L_1} \cap L_2) By distributive law of set theory:

    (L1∩L2)∪(L1‾∩L2)=(L1∪L1‾)∩L2=Σ∗∩L2=L2(L_1 \cap L_2) \cup (\overline{L_1} \cap L_2) = (L_1 \cup \overline{L_1}) \cap L_2 = \Sigma^* \cap L_2 = L_2

    Since L2L_2 is context-free, this language is context-free. Thus, (D) is a CFL.

Therefore, options B, C, and D are correct.

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 Q12 of the GATE CSE 2021 Set 2 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. 3 of them are 1-mark MSQs like this one, and GATE CSE 2021 Set 2 has 2.

How GATE tests Regular and Context-Free Languages

More from GATE CSE 2021 Set 2

Share this solution

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

GateAI solution cardGATE CSE 2021 Set 2 · Q12 · MSQ

Let L1 be a regular language and L2 be a context-free language. Which of the following languages is/are context-free?

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.