Skip to content
Official PYQ · 2025

GATE CS 2025 Set 1 Q34 — Regular and Context-free Languages

Explain with AI

Consider the following two languages over the alphabet {a,b}\{a, b\}:

L1={αβα∣α∈{a,b}+AND β∈{a,b}+}L2={αβα∣α∈{a}+AND β∈{a,b}+}\begin{array}{l} L_{1}=\left\{\alpha \beta \alpha \mid \alpha \in\{a, b\}^{+} \text{AND } \beta \in\{a, b\}^{+}\right\} \\ L_{2}=\left\{\alpha \beta \alpha \mid \alpha \in\{a\}^{+} \text{AND } \beta \in\{a, b\}^{+}\right\} \end{array}

Which ONE of the following statements is CORRECT?

Choose one option
View worked solution

Answer: C

To determine the regularity of the two languages, we analyze them individually:

1. Analysis of L1L_1:

L1={αβα∣α∈{a,b}+ and β∈{a,b}+}L_{1}=\left\{\alpha \beta \alpha \mid \alpha \in\{a, b\}^{+} \text{ and } \beta \in\{a, b\}^{+}\right\}

Let us intersect L1L_1 with the regular language R=ab+ab+R = a b^+ a b^+:

L1∩R={abnabm∣n,m≥1 and n≠m}L_1 \cap R = \left\{ a b^n a b^m \mid n, m \ge 1 \text{ and } n \neq m \right\}

To see why n≠mn \neq m, if n=mn = m, then any choice of prefix and suffix α\alpha starting with aa and ending with bb (i.e., α=abn\alpha = a b^n) forces β\beta to be empty, which is not allowed because β∈{a,b}+\beta \in \{a,b\}^+. Since {abnabm∣n≠m}\left\{ a b^n a b^m \mid n \neq m \right\} is a well-known non-regular language (provable by the pumping lemma) and regular languages are closed under intersection, L1L_1 is not regular.

2. Analysis of L2L_2:

L2={αβα∣α∈{a}+ and β∈{a,b}+}L_{2}=\left\{\alpha \beta \alpha \mid \alpha \in\{a\}^{+} \text{ and } \beta \in\{a, b\}^{+}\right\}

Since α∈{a}+\alpha \in \{a\}^+, we can write α=ak\alpha = a^k for some k≥1k \ge 1. Any string in L2L_2 is of the form akβaka^k \beta a^k with β∈{a,b}+\beta \in \{a, b\}^+. By choosing k=1k = 1, we can express any such string as:

aγawhere γ∈{a,b}+a \gamma a \quad \text{where } \gamma \in \{a, b\}^+

Thus, L2L_2 is simply the set of all strings over {a,b}\{a, b\} that start with aa, end with aa, and have a length of at least 33. This can be represented by the regular expression:

a(a+b)+aa(a+b)^+a

Since it can be defined by a regular expression, L2L_2 is regular.

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

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