GATE / CS ARCHIVE

GATE CSE 2002 / QUESTION 2.13

Automaton for lengths divisible by three

Theory of Computation · Finite Automata · Full GATE CSE 2002 paper

GATE 2002, Q2.13 2 marks · MCQ
Report issue

Finite Automata

Question 2.13, GATE 2002: How many states does the smallest finite automaton need to accept all strings whose lengths are divisible by 3?
(A) 2; (B) 3; (C) 4; (D) 5.
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step 1: Explain both construction and minimality.

Step 2: Label states 0,1,2 and send each state to its successor modulo 3 for every input symbol. Start and accept at 0. To distinguish residues r≠s, append a word of length(3−r) mod3: the state r accepts afterward and s does not. Thus no two residue states can be merged in a deterministic automaton.

Conclusion: Use three states for the input length modulo 3, advance the residue on every symbol, and accept residue 0. The three residues are distinguishable: append a length that brings one chosen residue to 0; it does not bring a different residue to 0. Thus a minimal DFA has 3 states, B, over a nonempty alphabet.

Original paper, page 5