GATE / CS ARCHIVE

GATE CSE 2025 SET 2 / QUESTION 52

GATE CSE 2025 Set 2 Q52

Theory of Computation · Regular Expressions & Languages · Full GATE CSE 2025 Set 2 paper

GATE 2025 Set 2, Q52 2 marks · MSQ
Report issue

Regular Expressions & Languages

Question 52, GATE 2025: Let #a(w),#b(w) count symbol occurrences. Which languages are regular?
A. {a^m b^n:m,n≥0}.
B. {a,b}* ∩ {a^m b^n c^(m−n):m≥n≥0}.
C. {w∈{a,b}*: #a(w)≡2 (mod 7), #b(w)≡3 (mod 9)}.
D. {w∈{a,b}*: #a(w)≡2 (mod 7), #a(w)=#b(w)}.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: A, C

A is described by the regular expression a*b*, so it is regular. The two block lengths are independent; there is no equality constraint to remember.

For B, membership in {a,b}* excludes every c. Hence m−n=0 and the intersection is exactly {an bn:n≥0}. This is nonregular: for a pumping length p, any allowed pumping segment in the initial a-block of ap bp changes the a-count without changing the b-count.

C needs only finite modular information. A DFA state (r,s) stores #a modulo 7 and #b modulo 9. On a update r to r+1 modulo 7; on b update s to s+1 modulo 9. Start at (0,0), accept (2,3). The 7·9=63-state construction proves regularity, without claiming a state-minimality result.

For D, intersect with the regular language a*b*. If D were regular, this intersection K={ak bk:k≡2 mod 7} would also be regular. Choose an allowed k greater than a proposed pumping length. Any pumping segment within the first p positions consists only of a's; pumping it changes one count and breaks equality. Thus K, and therefore D, is nonregular. A modular restriction alone is finite-state, but it does not eliminate an unbounded equality requirement. Select A,C.

Original paper, page 40 · Answer key