Skip to content
Official PYQ · 2021

GATE CS 2021 Set 2 Q47 — Regular Expressions and Finite Automata

Explain with AI

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 correct options
View worked solution

Answer: A;B;C

To find the regular expressions representing binary numbers divisible by 33, we construct the state transition diagram (DFA) where the states represent the remainder modulo 33:

  • q0q_0 (remainder 00): Start and accepting state.
  • q1q_1 (remainder 11): Non-accepting state.
  • q2q_2 (remainder 22): Non-accepting state.

The transition rules for a binary input xx are qnew=(2imesqold+x)(mod3)q_{new} = (2 imes q_{old} + x) \pmod 3:

  • From q0q_0: on 0→q00 \to q_0, on 1→q11 \to q_1
  • From q1q_1: on 0→q20 \to q_2, on 1→q01 \to q_0
  • From q2q_2: on 0→q10 \to q_1, on 1→q21 \to q_2

Option A & C:

Eliminating state q2q_2 first, the self-loop at q1q_1 via q2q_2 becomes 01∗001^*0. The path from q0q_0 to q1q_1 and back to q0q_0 becomes 1(01∗0)∗11(01^*0)^*1. Combining this with the self-loop 00 at q0q_0, we get the regular expression:

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

This matches Option A. Since (R∗S∗)∗(R^*S^*)^* is equivalent to (R+S)∗(R+S)^*, we can rewrite this as (0∗(1(01∗0)∗1)∗)∗(0^*(1(01^*0)^*1)^*)^*, which matches Option C.

Option B:

If we eliminate state q1q_1 first:

  • The path q0→q1→q0q_0 \to q_1 \to q_0 gives a self-loop of 1111 on q0q_0.
  • The path q2→q1→q2q_2 \to q_1 \to q_2 gives a self-loop of 0000 on q2q_2.
  • The transition q0→q1→q2q_0 \to q_1 \to q_2 becomes 1010.
  • The transition q2→q1→q0q_2 \to q_1 \to q_0 becomes 0101.

Now, the simplified system has states q0q_0 and q2q_2:

  • Self-loops on q0q_0: 0+110 + 11
  • Self-loops on q2q_2: 1+001 + 00
  • Path from q0q_0 to q2q_2 and back: 10(1+00)∗0110(1+00)^*01

Eliminating q2q_2 yields the regular expression:

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

This matches Option B.

Option D:

The binary representation of 99 is 100121001_2, which is divisible by 33. However, Option D cannot generate 100121001_2 because any string starting with 11 must begin with 1111 according to its terms, whereas 100121001_2 starts with 1010. Thus, Option D is incorrect.

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

Published
Report a correction
Keep exploringMore Regular Expressions and Finite Automata questions