GateAI
Regular Expressions and Finite Automata

GATE CSE 2020 · Q51

NAT2 marksMedium

Time

Consider the following language. L={x∈{a,b}∗∣ number of a’s in x is divisible by 2 but not divisible by 3}L = \{x \in \{a, b\}^*| \text{ number of } a\text{'s in } x \text{ is divisible by 2 but not divisible by 3}\} The minimum number of states in a DFA that accepts LL is _______.

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 6

Regular Expressions and Finite Automata

Let na(x)n_a(x) denote the number of occurrences of symbol 'aa' in string xx.

The condition states:

  1. na(x)n_a(x) is divisible by 2   ⟹  na(x)≡0(mod2)\implies n_a(x) \equiv 0 \pmod 2

  2. na(x)n_a(x) is not divisible by 3 $\implies n_a(x)

ot\equiv 0 \pmod 3$

Consider the count of aa's modulo lcm⁡(2,3)=6\operatorname{lcm}(2, 3) = 6:

  • na(x)(mod6)∈{0,1,2,3,4,5}n_a(x) \pmod 6 \in \{0, 1, 2, 3, 4, 5\}

  • Divisible by 2: {0,2,4}\{0, 2, 4\}

  • Not divisible by 3: {1,2,4,5}\{1, 2, 4, 5\}

  • The intersection is {2,4}\{2, 4\}.

Thus, the DFA must track na(x)(mod6)n_a(x) \pmod 6, requiring 6 states (corresponding to remainders 0,1,2,3,4,50, 1, 2, 3, 4, 5). By the Myhill-Nerode theorem, strings a0,a1,a2,a3,a4,a5a^0, a^1, a^2, a^3, a^4, a^5 are mutually distinguishable, so no states can be merged.

Therefore, the minimum number of states in the DFA is 6.

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 Expressions and Finite Automata previous year question is Q51 of the GATE CSE 2020 paper. Find more GATE CSE PYQs on Regular Expressions and Finite Automata 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 Expressions and Finite Automata 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 Expressions and Finite Automata in GATE CSE

Regular Expressions and Finite Automata has 41 GATE CSE PYQs across 24 papers from 2011 to 2026. 6 of them are 2-mark NAT questions like this one, and GATE CSE 2020 has 2.

How GATE tests Regular Expressions and Finite Automata

More from GATE CSE 2020

Share this solution

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

GateAI solution cardGATE CSE 2020 · Q51 · NAT

Consider the following language. L = {x ∈ {a, b}*| number of a's in x is divisible by 2 but not divisible by 3} The minimum number of states in a DFA that accepts L is …

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.