GateAI
Regular Expressions and Finite Automata

GATE CSE 2021 Set 2 · Q47

MSQ2 marksMedium

Time

Which of the following regular expressions represent(s) the set of all binary numbers that are divisible by three? Assume that the string ϵ\epsilon is divisible by three.

Select all that applyOne or more correct

Pick every correct option

Solution

Step-by-step verified solution

Official answer: A) (0 + 1(01*0)*1)*; B) (0 + 11 + 10(1 + 00)*01)*; C) (0*(1(01*0)*1)*)*

Regular Expressions and Finite Automata

To determine which regular expressions represent binary numbers divisible by 33, construct the standard DFA with states q0,q1,q2q_0, q_1, q_2 representing the remainder modulo 33 of the binary string read so far, where q0q_0 is both the initial state and the only accepting state.

The DFA transitions are:

  • δ(q0,0)=q0\delta(q_0, 0) = q_0, δ(q0,1)=q1\delta(q_0, 1) = q_1

  • δ(q1,0)=q2\delta(q_1, 0) = q_2, δ(q1,1)=q0\delta(q_1, 1) = q_0

  • δ(q2,0)=q1\delta(q_2, 0) = q_1, δ(q2,1)=q2\delta(q_2, 1) = q_2

Option A: Eliminating state q2q_2 first:

  • Path looping at q1q_1 through q2q_2: 01∗001^*0.

  • Path from q0q_0 to q0q_0 through q1q_1: 1(01∗0)∗11(01^*0)^*1.

  • Combined with the self-loop on 00 at q0q_0, the regular expression is:

    (0+1(01∗0)∗1)∗(0 + 1(01^*0)^*1)^*

Hence, Option A is correct.

Option C: Using the regular expression algebraic identity (r∗s∗)∗=(r+s)∗(r^*s^*)^* = (r+s)^*, substituting r=0r = 0 and s=1(01∗0)∗1s = 1(01^*0)^*1 gives:

(0∗(1(01∗0)∗1)∗)∗=(0+1(01∗0)∗1)∗(0^*(1(01^*0)^*1)^*)^* = (0 + 1(01^*0)^*1)^*

This is completely equivalent to Option A. Hence, Option C is correct.

Option B: Eliminating state q1q_1 by identifying all simple paths from q0q_0 back to q0q_0:

  • Direct loop on 00: 00

  • Path q0→1q1→1q0q_0 \xrightarrow{1} q_1 \xrightarrow{1} q_0: 1111

  • Path entering q2q_2 via q0→1q1→0q2q_0 \xrightarrow{1} q_1 \xrightarrow{0} q_2 (string 1010), looping in q2q_2 directly on 11 or via q2→0q1→0q2q_2 \xrightarrow{0} q_1 \xrightarrow{0} q_2 (string 0000), giving (1+00)∗(1 + 00)^*, and finally returning to q0q_0 via q2→0q1→1q0q_2 \xrightarrow{0} q_1 \xrightarrow{1} q_0 (string 0101): 10(1+00)∗0110(1 + 00)^*01.

  • The resulting regular expression is:

    (0+11+10(1+00)∗01)∗(0 + 11 + 10(1 + 00)^*01)^*

Hence, Option B is correct.

Option D: Option D can generate strings such as 111002=281011100_2 = 28_{10}. Since 28 mod 3=1≠028 \bmod 3 = 1 \neq 0, the expression generates numbers not divisible by 33. Thus, Option D is incorrect.

Therefore, options A, B, and C are correct.

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

How GATE tests Regular Expressions and Finite Automata

More from GATE CSE 2021 Set 2

Share this solution

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

GateAI solution cardGATE CSE 2021 Set 2 · Q47 · MSQ

Which of the following regular expressions represent(s) the set of all binary numbers that are divisible by three? Assume that the string is divisible by three.

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.