- GATE CS
- 2026–27 pattern practice
- Theory of Computation
- Finite automata
- Medium
How many states does the minimal DFA have that accepts all binary strings containing 101 as a substring?
Regular Languages
Pick an option to check your answer.
Answer: A. Solution
Track the longest suffix that matches a prefix of 101:
- q0: nothing useful yet.
- q1: the input ends in 1.
- q2: the input ends in 10.
- q3: 101 has been seen (accepting, loops on 0 and 1).
The four prefixes ε, 1, 10 and 101 are pairwise distinguishable, so no smaller DFA exists.
Why not the others
- is one too few: the DFA must separate 'no progress', 'seen 1', 'seen 10' and 'seen 101'.
- adds a separate dead state; once 101 is seen, the accepting state simply loops on both inputs.
- counts more prefixes than the language can tell apart.