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
GATE CSE 2021 Set 2 · Q47
Time
Select all that applyOne or more correct
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 AutomataTo determine which regular expressions represent binary numbers divisible by , construct the standard DFA with states representing the remainder modulo of the binary string read so far, where is both the initial state and the only accepting state.
The DFA transitions are:
,
,
,
Option A: Eliminating state first:
Path looping at through : .
Path from to through : .
Combined with the self-loop on at , the regular expression is:
Hence, Option A is correct.
Option C: Using the regular expression algebraic identity , substituting and gives:
This is completely equivalent to Option A. Hence, Option C is correct.
Option B: Eliminating state by identifying all simple paths from back to :
Direct loop on :
Path :
Path entering via (string ), looping in directly on or via (string ), giving , and finally returning to via (string ): .
The resulting regular expression is:
Hence, Option B is correct.
Option D: Option D can generate strings such as . Since , the expression generates numbers not divisible by . Thus, Option D is incorrect.
Therefore, options A, B, and C are correct.
Try the question first, then check your work.
Examiner trap
Construct the 3-state DFA for binary modulo 3 arithmetic and eliminate states using standard state elimination methods to find equivalent regular expressions. You can also use the algebraic equivalence .
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
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.
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 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 AutomataIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.