GATE / CS ARCHIVE

SIMILAR QUESTIONS / THEORY OF COMPUTATION

Track independent symbol counts with a product DFA

4 questions solved the same way, newest first. Back to Theory of Computation

How these are solved

Track one residue for each symbol count and distinguish the reachable residue pairs. Divisors vary; the 1997 variant asks to construct a minimum machine while the later variants ask its state count.

2 marks · MCQ
Report issue

Minimal DFA for two modular counts

Finite Automata

Question 29, GATE 2007: What is the number of states in a minimum DFA for L={w∈{0,1}*: the number of 0s is divisible by 3 and the number of 1s is divisible by 5}?
Options:
(A) 15
(B) 11
(C) 10
(D) 9
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step through it (2 parts)

1. Approach. Use a product state (i,j) recording the two remainders. On 0 update i modulo 3; on 1 update j modulo 5. Minimality requires distinguishability, not merely constructing a 15-state DFA.

2. Derivation and interpretation. Track the number of zeros modulo 3 and ones modulo 5, giving 3×5=15 states; accept residue (0,0). Every residue pair is reachable. Any two different pairs are distinguished by appending zeros and ones that bring one pair to (0,0), leaving the other nonzero in at least one coordinate. Thus 15 states are necessary and sufficient, A.

Original paper, page 6

2 marks · MCQ
Report issue

Product automaton for counts modulo three and two

Finite Automata

Question 86, GATE 2004: A DFA has six states arranged as top row t0,t1,t2 and bottom row b0,b1,b2. Initial and sole accepting state is t0. On 1, each row cycles left-to-right: t0→t1→t2→t0 and b0→b1→b2→b0. On 0, each column toggles tj↔bj. Which condition on (#1,#0) describes the accepted strings?
Options:
(A) Divisible by 3 and 2 respectively
(B) Odd and even respectively
(C) Even and odd respectively
(D) Divisible by 2 and 3 respectively
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. Label each of the three columns by the count of ones modulo 3, from left to right 0,1,2; label upper and lower rows by the count of zeros modulo 2, 0 and 1. Each 1 edge advances one column cyclically without changing row, and each 0 edge toggles the row without changing column.

2. The initial upper-left state is the only accepting state. Hence acceptance requires #1≡0 mod3 and #0≡0 mod2, option A, including the empty string.

3. Teaching check: The two counters are independent: reading 1 changes the column but not the row, and reading 0 changes the row but not the column. Returning to t0 requires both modular counts to return to zero. The empty word is accepted because the start state is accepting.

Original paper, page 12

2 marks · MCQ
Report issue

DFA tracking two independent modular counts

Finite Automata

Question 2.5, GATE 2001: Find the minimum DFA size over {a,b} accepting exactly strings whose a-count is divisible by 6 and b-count by 8. Options: 8,14,15,48.
Question 2.5, GATE 2001: Find the minimum DFA size over {a,b} accepting exactly strings whose a-count is divisible by 6 and b-count by 8. Options: 8,14,15,48.
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Step 1: Store a pair(i,j), where i is the number of a symbols modulo 6 and j the number of b symbols modulo 8. Reading a increments only i; reading b increments only j. Accept(0,0). This constructs 6·8=48 states.

Step 2: Every pair is reached by ai bj. For two distinct pairs, append a number of a and b symbols that brings the first pair to(0,0). The second pair retains a nonzero difference in at least one residue and rejects. Thus all pairs are distinguishable.

The construction is minimal, giving 48, D, not the sum 6+8.

Original paper, page 4

5 marks · Descriptive
Report issue

Minimum DFA for two divisibility conditions

Finite Automata

Question 20, GATE 1997: Construct a finite-state machine with the minimum number of states accepting exactly the strings over {a,b} whose number of a symbols is divisible by 2 and number of b symbols is divisible by 3.
Tap to enlarge
Answer & solution

Answer: Six-state DFA tracking (#a mod 2, #b mod 3); start and only accepting state q00. (no official key was published)

Step through it (2 parts)

The future acceptance of a prefix depends on two remainders, not on the order of its symbols. Let qij mean that the prefix contains i a's modulo 2 and j b's modulo 3. Use Q={q00,q01,q02,q10,q11,q12}; start at q00 and make only q00 accepting. An a toggles i, while a b advances j modulo 3.

State    on a    on b    Accepting?
q00      q10     q01     yes
q01      q11     q02     no
q02      q12     q00     no
q10      q00     q11     no
q11      q01     q12     no
q12      q02     q10     no

This table completely specifies the machine and can be drawn as two three-state b-cycles with paired a-transitions between them. By induction on input length, its state is always the pair of remainders claimed above. Therefore it accepts exactly the required strings, including the empty string because zero is divisible by both divisors.

To prove minimum size, first note that every qij is reachable by ai bj. Next take any distinct qij and qkl. Append the suffix a^((-i) mod 2)b^((-j) mod 3). From qij this reaches q00 and accepts. From qkl it reaches the nonzero remainder pair ((k−i) mod 2,(l−j) mod 3), so it rejects. Every pair of states is thus distinguishable by a common suffix. The six distinct residual languages require at least six DFA states; our six-state construction meets this lower bound. Merely multiplying 2 by 3 would suggest the answer but would not, without distinguishability, prove minimality.

Original paper, page 9