Epsilon free NFA to DFA Conversion - Examples

 

Every nondeterministic finite automaton (NFA) can be converted to a deterministic finite automaton (DFA).

Subset construction(power set construction) is a method to convert an NFA (Nondeterministic Finite Automaton) to an equivalent DFA (Deterministic Finite Automaton).
It works by treating each DFA state as a set of NFA states.

🔹 Algorithm (ε-free version):

  1. Initial DFA state: A set containing just the initial state of the NFA.

  2. For each DFA state S and each input symbol a:

    • Let T = ∪ δ(q, a) for all q ∈ S

    • T becomes a new DFA state (if not already present).

    • Create a transition from S to T on a.

  3. Repeat until all states and transitions are constructed.

  4. Accepting states of DFA: All those DFA states containing at least one accepting NFA state.

✅ Important Notes:

  • This is a mechanical process.

  • No ε-closure computation is required.

  • The DFA might have up to 2ⁿ states if the NFA has n states.

  • The resulting DFA accepts the same language as the original NFA.

  • The method guarantees equivalence and termination

Example 1: NFA to DFA Conversion

Problem: Draw an NFA that accepts all the strings ending with “1” over Σ {0,1} and convert this NFA to its corresponding DFA.

Step 01: Draw NFA Graph

The following is the NFA graph 

Step 02: Draw the NFA transition Table.

The NFA transition table of the above NFA is given below

Step 03: Conversion of NFA To DFA transition Table

First, Select the first row of the NFA transition table, which will become the first  row of the DFA transition table. It is given below


The q0q1 is a new state and will be added to the states column. Following is the Transitions for q0q1.


The transition of q0q1 against input 0 is q0, and the transition against input 1 is q0q1. Hence, the updated DFA table is given below.


At this stage, all newly generated states are executed successfully for their transitions. So, the DFA table is ready.

Important: As q1 was the final state in NFA Table. That’s why, all those states will be the final states where q1 is present. Simply mark with “*” to represent the final state. 

So, the following is the updated table of DFA with its final states


Step 4: Now draw DFA according to the DFA transition table

The DFA transition table contains two states (q0, q0q1) in its state column. Thus, the desired DFA machine graph will contain these similar states, and transitions will be made according to the DFA transition table.


Example 02: NFA to DFA Conversion

Problem: Draw an NFA of all binary strings in which the 2nd last bit is 1 and convert this NFA to its corresponding DFA.

Step 01: Draw NFA Graph.

The following is the NFA graph


Step 02: Draw the NFA transition Table.

The NFA transition table of the above NFA is given below

Step 03: Conversion of NFA To DFA transition Table

First, Select the first row of the NFA transition table, which will become the first  row of the DFA transition table. It is given below


The q0q1 is a new state and will be added to the states column. Following is the Transitions for q0q1.

([q0q1], 0) = δ(q0, 0) ∪ δ(q1, 0)  

                      = {q0} ∪ {q2}  

                      = [q0q2]  // new state generated

δ([q0q1], 1) = δ(q0, 1) ∪ δ(q1, 1)  

                      = {q0q1} ∪ {q2}  

                      = {q0q1q2}  // new state generated

The transition of q0q1 against input 0 is q0q2, and the transition against input 1 is q0q1q2. Hence, the updated DFA table is given below.


q0q2 and q0q1q2 are the new states for the states column. We need to find the transitions for both newly generated states. Following is the Transitions for q0q2.

δ([q0q2], 0) = δ(q0, 0) ∪ δ(q2, 0)  

                      = {q0} 

                      = [q0]   // already found in DFA table

δ([q0q2], 1) = δ(q0, 1) ∪ δ(q2, 1)  

                      = {q0q1}

                      = {q0q1}  

                      = [q0q1]  // already found in DFA table

The transition of q0q2 against input 0 is q0, and the transition against input 1 is q0q1. Hence, the updated DFA table is given below.

Following is the Transitions for q0q1q2.

δ([q0q1q2], 0) = δ(q0, 0) ∪ δ(q1, 0)  ∪ δ(q2, 0)  

                      = {q0} ∪ {} ∪ {q2}

                      = [q0q2]   // already found in DFA table

δ([q0q1q2], 1) = δ(q0, 1) ∪ δ(q1, 1)  ∪ δ(q2, 1)   

                      = {q0} ∪ {q1} ∪ {q2}

                      = [q0q1q2]  // already found in DFA table

The transition of q0q1q2 against input 0 is q0q2, and the transition against input 1 is q0q1q2. Hence, the updated DFA table is given below.

At this stage, all newly generated states are executed successfully for their transitions. So, the DFA table is ready.

Important: As q2 was the final state in NFA, all those states will be the final in DFA where q2 exists. Therefore, the DFA Table with all its final states is given under,


Step 4: Now draw DFA according to the DFA transition table

The DFA transition table contains four states (q0, q0q1, q0q2, q0q1q2) in its state column. Thus, the desired DFA machine graph will contain these similar states, and transitions will be made according to the DFA transition table.


Example 3: NFA to DFA Conversions

The following is the NFA graph that needs to be converted to a DFA.


Step 02: Draw the NFA transition Table.

The following is the NFA transition table which is derived from the given NFA.

Step 03: Conversion of NFA To DFA transition Table

First, Select the first  rows of the NFA transition table, which will become the first  row of the DFA transition table. It is given below

The q0q1 is a new state (as it does not exist in the NFA table) and will be added to the states column of the DFA table. Following is the Transitions for q0q1.

δ([q0q1], 0) = δ(q0, 0) ∪ δ(q1, 0)  

                      = {q0q1} ∪ {ϕ}  

                      = {q0q1}

δ([q0q1], 1) = δ(q0, 1) ∪ δ(q1, 1)  

                      = {q1} ∪ {q0q1}  

                      = {q0q1}

Following is the updated DFA table

The q1 is a new state and will be added to the states column. Following is the Transitions for q1.

δ([q1], 0) = {qϕ}  

δ([q1], 1) = {q0q1}

The following is the updated DFA table with all  its final states

The above given is the required DFA table

Important: As q1 was the final state in NFA Table. That’s why, all those states will be the final states where q1 is present. Simply mark with “*” to represent the final state.

Step 4: Now draw DFA according to the DFA transition table

The following is the converted DFA from the given NFA.



Comments

Popular posts from this blog

Theory Of Computation PCCST302 KTU Semester 3 BTech 2024 Scheme

Non deterministic Finite Automata NFA

Example DFAs University Questions