How to convert from NFA to DFA in TOC?

Data Structure AlgorithmsComputer ScienceComputers

In Non-Deterministic Finite Automata, for any current state and input symbol, there exists more than one next output state.

Any string is accepted if and only if there exists at least one transition path which is starting at initial state and ending at final state.

The following steps are followed to convert a given NFA to a DFA −

Algorithm

Step-01

  • Let's take ' q’ as a new set of states of the DFA. It is declared null in the beginning.
  • Let's take T’ be a new transition table of the DFA.

Step-02

  • Add the start state of the NFA to q’.
  • Add transitions from the start state to the T’.
  • If the start state has transition to multiple states for some input alphabet, then accept those multiple states as a single state in the DFA.

Step-03

If any new state is present in T’,

  • Add the new state in q’.
  • Add transitions of state in the transition table T’.

Step-04

  • Keep repeating the third step until no new state is present in the transition table T’.
  • Finally, the transition table T’ so obtained is the complete transition table of the required DFA.

Note

After conversion, the number of states in DFA may or may not be the same as NFA.

The max number of states that are present in the DFA are two numbers of states in the NFA.

The number of states in NFA and DFA −

1 <= n <= 2m

Here,

  • n = Number of states in the DFA
  • m = Number of states in the NFA

In the resulting DFA, all those states that contain the final state(s) of NFA are treated as final states.

raja
Updated on 12-Jun-2021 09:14:20

Advertisements