Prerequisite – Finite Automata

**1. DFA :**

DFA refers to Deterministic Finite Automaton. A Finite Automata(FA) is said to be deterministic, if corresponding to an input symbol, there is single resultant state i.e. there is only one transition.

A deterministic finite automata is set of five tuples and represented as,

Where,

Q: A non empty finite set of states present in the finite control(qo, q1, q2, …).

Σ: A non empty finite set of input symbols.

δ: It is a transition function that takes two arguments, a state and an input symbol, it returns a single state.

qo: It is starting state, one of the state in Q.

F: It is non-empty set of final states/ accepting states from the set belonging to Q.

**2. NFA :**

NFA refers to Nondeterministic Finite Automaton. A Finite Automata(FA) is said to be non deterministic, if there is more than one possible transition from one state on the same input symbol.

A non deterministic finite automata is also set of five tuples and represented as,

Where,

Q: A set of non empty finite states.

Σ: A set of non empty finite input symbols.

δ: It is a transition function that takes a state from Q and an input symbol from and returns a subset of Q.

qo: Initial state of NFA and member of Q.

F: A non-empty set of final states and member of Q.

**Difference between DFA and NFA :**

SR.NO. | DFA | NFA |
---|---|---|

1 | DFA stands for Deterministic Finite Automata. | NFA stands for Nondeterministic Finite Automata. |

2 | For each symbolic representation of the alphabet, there is only one state transition in DFA. | No need to specify how does the NFA react according to some symbol. |

3 | DFA cannot use Empty String transition. | NFA can use Empty String transition. |

4 | DFA can be understood as one machine. | NFA can be understood as multiple little machines computing at the same time. |

5 | In DFA, the next possible state is distinctly set. | In NFA, each pair of state and input symbol can have many possible next states. |

6 | DFA is more difficult to construct. | NFA is easier to construct. |

7 | DFA rejects the string in case it terminates in a state that is different from the accepting state. | NFA rejects the string in the event of all branches dying or refusing the string. |

8 | Time needed for executing an input string is less. | Time needed for executing an input string is more. |

9 | All DFA are NFA. | Not all NFA are DFA. |

10 | DFA requires more space. | NFA requires less space then DFA. |

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 of Epsilon-NFA to NFA
- 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
- 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
- ∈-NFA of Regular Language L = {ab,ba}
- ∈-NFA of L = (a* + b*)
- DFA in LEX code which accepts even number of zeros and even number of ones
- DFA of a string with at least two 0’s and at least two 1’s
- DFA machines accepting odd number of 0’s or/and even number of 1’s
- DFA for strings not containing consecutive two a's and starting with 'a'
- Construct a DFA which accept the language L = {w | w ∈ {a,b}* and Na(w) mod 3 = Nb (w) mod 3}
- Program to build a DFA to accept strings that start and end with same character
- DFA for exactly one of a and at least one of b
- DFA of alternate 0's and 1's
- Program to build a DFA that accepts strings starting and ending with different character

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.