The Wayback Machine - https://web.archive.org/web/20261119001105/https://www.geeksforgeeks.org/theory-of-computation/conversion-from-nfa-to-dfa/

Conversion from NFA to DFA

Last Updated : 18 Nov, 2026

An NFA can have zero, one, or multiple transitions from a state on an input symbol. An ε-NFA can also have ε-transitions, which do not consume any input symbol. A DFA has exactly one transition for each state and input symbol.

Steps for converting NFA to DFA

Step 1: Create the DFA start state

The DFA start state is the ε-closure of the NFA's initial state. The ε-closure of a state includes the state itself and all states reachable from it using zero or more ε-transitions.

Step 2: Calculate DFA transitions

For each DFA state (a set of NFA states) and each input symbol, calculate the next set of states using:

δ'(S, a) = ε-closure(∪ δ(q, a)), for every q ∈ S

Here, S is a set of NFA states, a is an input symbol, and δ' is the DFA transition function.

Add each newly generated state set to the DFA and calculate its transitions. Repeat until no new state sets are generated. If a transition produces the empty set, include the empty set as a DFA state.

Step 3: Identify final states

A DFA state is final if its set contains at least one final state of the NFA. The resulting DFA recognizes the same language as the original NFA.

Example: Conversion of NFA to DFA

Consider the following NFA:

 

The NFA has the following parameters:

  • Q = {q0, q1, q2}
  • Σ = {a, b}
  • Initial state = q0
  • F = {q2}

Its transition table is:

 

The initial DFA state is {q0}. Using the NFA transition function, calculate the transitions for each input symbol.

 

The resulting state {q0, q1} is added to the DFA. Calculate its transitions:

  • δ'({q0, q1}, a) = {q0, q1}
  • δ'({q0, q1}, b) = {q0, q2}
 

Next, add {q0, q2} and calculate its transitions:

  • δ'({q0, q2}, a) = {q0, q1}
  • δ'({q0, q2}, b) = {q0}
 

No new state sets are generated, so the conversion is complete.

The resulting DFA has:

  • Q' = {{q0}, {q0, q1}, {q0, q2}}
  • Σ = {a, b}
  • F' = {{q0, q2}}
  • δ' = As shown in the transition tables above.

The final DFA is shown below:

 

Minimization of DFA

The DFA obtained through subset construction may contain unreachable or equivalent states. These states can be removed or merged through DFA minimization. However, minimization is a separate process and is not required for NFA-to-DFA conversion.

Conversion from Regular Expression to DFA

A regular expression can first be converted into an equivalent NFA, which can then be converted into a DFA using subset construction.

 

 

 

 

Comment

Explore