Skip to content
Official PYQ · 2011

GATE CS 2011 Q24 — Regular and Context-free Languages

Explain with AI

Let PP be a regular language and QQ be a context-free language such that Q⊆PQ \subseteq P. (For example, let PP be the language represented by the regular expression p∗q∗p^*q^* and QQ be {pnqn∣n∈N})\{p^nq^n \mid n \in N\}). Then which of the following is ALWAYS regular?

Choose one option
View worked solution

Answer: C

To determine which of the given languages is always regular, let us analyze each option using the closure properties of regular and context-free languages (CFLs):

  • Option A: P∩QP \cap Q
    Since Q⊆PQ \subseteq P, we have P∩Q=QP \cap Q = Q. Since QQ is a context-free language, it is not necessarily regular (for example, Q={pnqn∣n≥0}Q = \{p^n q^n \mid n \ge 0\} is context-free but not regular). Thus, P∩QP \cap Q is not always regular.
  • Option B: P−QP - Q
    Using the example given in the question, let P=p∗q∗P = p^*q^* (regular) and Q={pnqn∣n≥0}Q = \{p^n q^n \mid n \ge 0\} (CFL). Then:
    P−Q={paqb∣a≠b,a≥0,b≥0}P - Q = \{p^a q^b \mid a \neq b, a \ge 0, b \ge 0\}
    This language is context-free but not regular. Thus, P−QP - Q is not always regular.
  • Option C: Σ∗−P\Sigma^* - P
    The language Σ∗−P\Sigma^* - P is the complement of PP (denoted as P‾\overline{P}). Since PP is a regular language, and regular languages are closed under complementation, P‾\overline{P} is guaranteed to be regular.
  • Option D: Σ∗−Q\Sigma^* - Q
    The language Σ∗−Q\Sigma^* - Q is the complement of QQ (denoted as Q‾\overline{Q}). The complement of a non-regular CFL is not necessarily regular (and indeed, context-free languages are not closed under complementation). Thus, Σ∗−Q\Sigma^* - Q is not always regular.

Therefore, only Σ∗−P\Sigma^* - P is always regular.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Regular and Context-free Languages questions