Skip to content
Mad4Study

Engineering & Science

GATE Computer Science

  • 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.

Track the longest suffix that matches a prefix of 101:

  1. q0: nothing useful yet.
  2. q1: the input ends in 1.
  3. q2: the input ends in 10.
  4. 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

  • 33 is one too few: the DFA must separate 'no progress', 'seen 1', 'seen 10' and 'seen 101'.
  • 55 adds a separate dead state; once 101 is seen, the accepting state simply loops on both inputs.
  • 66 counts more prefixes than the language can tell apart.

Report an error

GATE CS · Theory of Computation · Regular Languages