**Non-deterministic Finite Automata (NFA)** is a finite automata having zero, one or more than one moves from a given state on a given input symbol. Epsilon NFA is the NFA which contains epsilon move(s)/Null move(s). To remove the epsilon move/Null move from epsilon-NFA and to convert it into NFA, we follow the steps mentioned below.

**Figure –**Vertex v1 and Vertex v2 having an epsilon move

**Step-1:**

Consider the two vertexes having the epsilon move. Here in *Fig.1* we have vertex v1 and vertex v2 having epsilon move from v1 to v2.

**Step-2:**

Now find all the moves to any other vertex that start from vertex v2 *(other than the epsilon move that is considering).*

After finding the moves, duplicate all the moves that start from vertex v2, with the same input to start from vertex v1 and remove the epsilon move from vertex v1 to vertex v2.

**Step-3:**

See that if the vertex v1 is a start state or not. If vertex v1 is a start state, then we will also make vertex v2 as a start state. If vertex v1 is not a start state, then there will not be any change.

**Step-4:**

See that if the vertex v2 is a final state or not.

If vertex v2 is a final state, then we will also make vertex v1 as a final state.

If vertex v2 is not a final state, then there will not be any change.

Repeat the steps*(from step 1 to step 4)* until all the epsilon moves are removed from the NFA.

Now, to explain this conversion, let us take an example.

**Example:** Convert epsilon-NFA to NFA.

Consider the example having states q0, q1, q2, q3, and q4.

In the above example, we have 5 states named as q0, q1, q2, q3 and q4. Initially, we have q0 as start state and q2 as final state. We have q1, q3 and q4 as intermediate states.

Transition table for the above NFA is:

States/Input | Input 0 | Input 1 | Input epsilon |
---|---|---|---|

q0 | – | q1 | q2 |

q1 | – | q0 | – |

q2 | q3 | q4 | – |

q3 | q2 | – | – |

q4 | q2 | – | – |

According to the transition table above,

- state q0 on getting input 1 goes to state q1.
- State q0 on getting input as a null move
*(i.e. an epsilon move)*goes to state q2. - State q1 on getting input 1 goes to state q0.
- Similarly, state q2 on getting input 0 goes to state q3, state q2 on getting input 1 goes to state q4.
- Similarly, state q3 on getting input 0 goes to state q2.
- Similarly, state q4 on getting input 0 goes to state q2.

We can see that we have an epsilon move from state q0 to state q2, which is to be removed.

To remove epsilon move from state q0 to state q1, we will follow the steps mentioned below.

**Step-1:**

Considering the epsilon move from state q0 to state q2. Consider the state q0 as vertex v1 and state q2 as vertex v2.

**Figure –**State q0 as vertex v1 and state q2 as vertex v2

**Step-2:**

Now find all the moves that starts from vertex v2 *(i.e. state q2)*.

After finding the moves, duplicate all the moves that start from vertex v2 *(i.e state q2)* with the same input to start from vertex v1 *(i.e. state q0)* and remove the epsilon move from vertex v1 *(i.e. state q0)* to vertex v2 *(i.e. state q2)*.

Since state q2 on getting input 0 goes to state q3.

Hence on duplicating the move, we will have state q0 on getting input 0 also to go to state q3.

Similarly state q2 on getting input 1 goes to state q4.

Hence on duplicating the move, we will have state q0 on getting input 1 also to go to state q4.

So, NFA after duplicating the moves is:

**Figure –**NFA on duplicating moves

**Step-3:**

Since vertex v1 *(i.e. state q0)* is a start state. Hence we will also make vertex v2 *(i.e. state q2)* as a start state.

Note that state q2 will also remain as a final state as we had initially.

NFA after making state q2 also as a start state is:

**Figure –**NFA after making state q2 as a start state

**Step-4:**

Since vertex v2 *(i.e. state q2)* is a final state. Hence we will also make vertex v1 *(i.e. state q0)* as a final state.

Note that state q0 will also remain as a start state as we had initially.

After making state q0 also as a final state, the resulting NFA is:

**Figure –**Resulting NFA (state q0 as a final state)

The transition table for the above resulting NFA is:

States/Input | Input 0 | Input 1 |
---|---|---|

q0 | q3 | q1,q4 |

q1 | – | q0 |

q2 | q3 | q4 |

q3 | q2 | – |

q4 | q2 | – |

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

## Recommended Posts:

- Conversion from NFA to DFA
- Program to Implement NFA with epsilon move to DFA Conversion
- Hypothesis (language regularity) and algorithm (L-graph to NFA) in TOC
- Regular expression to ∈-NFA
- NFA machines accepting all strings that ends or not ends with substring 'ab'
- NFA to accept strings that has atleast one character occurring in a multiple of 3
- Difference between DFA and NFA
- NFA which accepts set of strings over an alphabet {0, 1, 2} such that the final digit has appeared before
- NFA for language at least one of the symbols occurring an odd number of times
- Program for Binary To Decimal Conversion
- Program for Decimal to Binary Conversion
- Program for Octal to Decimal Conversion
- Conversion of Moore to Mealy machine (Set 4)
- Conversion of Moore to Mealy machine (Set 10)
- Conversion of Moore to Mealy machine (Set 9)
- Conversion of Binary number to Base 4 system
- Conversion of S-R Flip-Flop into T Flip-Flop
- Difference between Type Casting and Type Conversion
- Conversion of J-K Flip-Flop into T Flip-Flop
- Conversion of J-K Flip-Flop into D Flip-Flop

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.