Question

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.

Choose every correct option
Official answer and solution
Official answer
A, B and C
From
Official GATE 2021 answer key

Solution

Use the standard 3-state remainder DFA for binary numbers modulo 3 and derive equivalent regular expressions via state elimination.

The DFA recognizing binary strings divisible by 3 has states q0q_0 (remainder 0, start and accept state), q1q_1 (remainder 1), and q2q_2 (remainder 2):

  • From q0q_0: on 0 goes to q0q_0; on 1 goes to q1q_1
  • From q1q_1: on 0 goes to q2q_2; on 1 goes to q0q_0
  • From q2q_2: on 0 goes to q1q_1; on 1 goes to q2q_2

Deriving expression via state elimination:

  1. Eliminate state q2q_2:
    State q2q_2 has a self-loop on 1 (1∗1^*).
    The path from q1q_1 through q2q_2 and back to q1q_1 is 01∗00 1^* 0.
    Thus, at q1q_1, the self-loop is (01∗0)∗(0 1^* 0)^*.
    From q1q_1, transitioning to q0q_0 on 1 gives the path expression 1(01∗0)∗11 (0 1^* 0)^* 1 from q0q_0 through q1q_1 back to q0q_0.
    Combining with the self-loop on 0 at q0q_0, the overall regular expression is:
    (0+1(01∗0)∗1)∗(0 + 1 (0 1^* 0)^* 1)^*
    This matches option A.
  1. Equivalence of Option C:
    Using the regular identity (R∗S∗)∗=(R+S)∗(R^* S^*)^* = (R + S)^*, setting 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)^*. Thus, option C represents the exact same language and is correct.
  1. Eliminate state q1q_1 first:
    • From q0q_0, paths to q0q_0 directly: 0 and 1111.
    • Paths between q0q_0 and q2q_2: q0→q1→q2q_0 \to q_1 \to q_2 gives 1010, and q2→q1→q0q_2 \to q_1 \to q_0 gives 0101.
    • Self loop at q2q_2: 1 (direct) or 0000 (via q1q_1), giving (1+00)(1 + 00).
    • Connecting from q0q_0 through q2q_2 back to q0q_0 gives 10(1+00)∗0110 (1 + 00)^* 01.
    • Combined with direct loops at q0q_0, the expression is:
    (0+11+10(1+00)∗01)∗(0 + 11 + 10(1 + 00)^* 01)^*
    This precisely matches option B.

Option D has the term 11(1+00)∗0011(1+00)^*00 instead of 10(1+00)∗0110(1+00)^*01, which produces invalid strings that are not multiples of 3 (for instance, 11100=2811100 = 28, which is not divisible by 3). Therefore, option D is incorrect.

Final answer

A, B, C

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2021 Computer Science and Information Technology - Session 2 (CS2)
Question
57 of 65, printed as CS Q.47
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.