Skip to main content

Difference between DFA and NFA

Short answer

A DFA has exactly one transition per symbol from each state and no ε-moves, while an NFA may have multiple or zero transitions and can include ε-moves. NFAs are often more compact and easier to design, but DFAs are simpler to implement. Both recognize the same class of regular languages, convertible via the subset construction.

Differentiate between DFA and NFA (NDFA).

Both DFA and NFA accept exactly the regular languages, but they differ in how they move.

PointDFANFA (NDFA)
Transition functionδ : Q × Σ → Qδ : Q × (Σ ∪ {ε}) → 2^Q
Moves on a symbolexactly one next statezero, one or many next states
ε-movesnot allowedallowed (ε-NFA)
Computationa single path for each inputa tree of paths; accept if some path ends in a final state
Dead stateneeded to make δ totalmissing transitions are allowed (the path simply dies)
Acceptanceδ*(q₀, w) ∈ Fδ*(q₀, w) ∩ F ≠ ∅
Designharder, more stateseasier, usually fewer states
Implementationsimple and fast, one table lookup per symbolneeds backtracking or tracking a set of states
Number of statesnan NFA with n states may need up to 2ⁿ states as a DFA

Formal tuple: both are 5-tuples (Q, Σ, δ, q₀, F); only the type of δ differs.

Equivalence. Every NFA can be converted to a DFA by the subset construction, so the two models accept the same class of languages (regular languages).

✓ Answer checked by Claude Opus 5.5 (high effort)

All Theory of Computation chapter 2 questions →