GateAI
Regular and Context-Free Languages

GATE CSE 2025 Set 2 · Q52

MSQ2 marksMedium

Time

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 that applyOne or more correct

Pick every correct option

Solution

Step-by-step verified solution

Official answer: A) {am bn m, n ≥ 0}; C) {w w ∈ {a, b}*, \#a(w) 2 (mod 7), and \#b(w) 3 (mod 9)}

Regular and Context-Free Languages

Let us analyze each of the given languages:

  • Option (A): The language is {ambn∣m,n≥0}\{a^m b^n \mid m, n \ge 0\}, which corresponds directly to the regular expression a∗b∗a^*b^*. Since it can be generated by a regular expression, it is regular.

  • Option (B): The language is {a,b}∗∩{ambncm−n∣m≥n≥0}\{a, b\}^* \cap \{a^m b^n c^{m-n} \mid m \ge n \ge 0\}. Any string in {ambncm−n∣m≥n≥0}\{a^m b^n c^{m-n} \mid m \ge n \ge 0\} that contains no occurrences of the symbol cc must satisfy m−n=0  ⟹  m=nm - n = 0 \implies m = n. Thus, the intersection evaluates to {anbn∣n≥0}\{a^n b^n \mid n \ge 0\}, which is well-known to be non-regular (requires unbounded memory to match the counts of aa and bb).

  • Option (C): The language is {w∣w∈{a,b}∗,#a(w)≡2(mod7) and #b(w)≡3(mod9)}\{w \mid w \in \{a, b\}^*, \#_a(w) \equiv 2 \pmod 7 \text{ and } \#_b(w) \equiv 3 \pmod 9\}. This is the intersection of two regular languages (one keeping track of the count of aa's modulo 77, requiring 77 states, and the other keeping track of the count of bb's modulo 99, requiring 99 states). A product DFA with 7×9=637 \times 9 = 63 states can recognize it, so it is regular.

  • Option (D): The language requires strings over {a,b}\{a, b\} to satisfy both #a(w)≡2(mod7)\#_a(w) \equiv 2 \pmod 7 and #a(w)=#b(w)\#_a(w) = \#_b(w). If we intersect this language with the regular language a∗b∗a^* b^*, we get {akbk∣k≥0 and k≡2(mod7)}\{a^k b^k \mid k \ge 0 \text{ and } k \equiv 2 \pmod 7\}. Using the Pumping Lemma, this language is non-regular; hence the original language is not regular.

Therefore, the correct options are A and C.

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 Q52 of the GATE CSE 2025 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. 4 of them are 2-mark MSQs like this one, and GATE CSE 2025 Set 2 has 2.

How GATE tests Regular and Context-Free Languages

More from GATE CSE 2025 Set 2

Share this solution

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

GateAI solution cardGATE CSE 2025 Set 2 · Q52 · MSQ

Let = {a, b, c}. For x ∈ *, and ∈ , let \# (x) denote the number of occurrences of in x. Which one or more of the following option(s) define(s) regular language(s)?

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.