Skip to content
Official PYQ · 2025

GATE CS 2025 Set 2 Q42 — Regular and Context-free Languages

Explain with AI

Let Σ={a,b,c}\Sigma=\{a, b, c\}. For x∈Σ∗x \in \Sigma^{*}, and α∈Σ\alpha \in \Sigma, let #α(x)\#_{\alpha}(x) denote the number of  occurrences of α\alpha in xx. 

Which one or more of the following option(s) define(s) regular language(s)?
 

Select all correct options
View worked solution

Answer: A;C

We analyze each option to determine if the defined language is regular:

  • Option A: The language is {ambn∣m,n≥0}\{a^m b^n \mid m, n \geq 0\}, which can be represented by the regular expression a∗b∗a^*b^*. Thus, it is regular.
  • Option B: The second set contains strings of the form ambncm−na^m b^n c^{m-n} where m≥n≥0m \geq n \geq 0. Intersecting this set with {a,b}∗\{a, b\}^* means we only retain strings that contain no cc symbols. This requires the exponent of cc to be zero: m−n=0  ⟹  m=nm - n = 0 \implies m = n Thus, the language simplifies to {anbn∣n≥0}\{a^n b^n \mid n \geq 0\}, which is a well-known non-regular language.
  • Option C: Let L1={w∈{a,b}∗∣#a(w)≡2(mod7)}L_1 = \{w \in \{a, b\}^* \mid \#_a(w) \equiv 2 \pmod 7\} and L2={w∈{a,b}∗∣#b(w)≡3(mod9)}L_2 = \{w \in \{a, b\}^* \mid \#_b(w) \equiv 3 \pmod 9\}. Both L1L_1 and L2L_2 are regular because modulo counting can be done using finite state automata (with 77 and 99 states, respectively). Since regular languages are closed under intersection, L1∩L2L_1 \cap L_2 is regular.
  • Option D: This language requires checking the condition #a(w)=#b(w)\#_a(w) = \#_b(w), which requires infinite memory (a stack) to compare the exact counts of aa and bb. Thus, it is non-regular.

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

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