![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the difference between DFA and NFA?
DFA is the short form for the deterministic finite automata and NFA is for the Non-deterministic finite automata. Now, let us understand in detail about these two finite automata.
DFA
A Deterministic Finite automata is a five-tuple automata. Following is the definition of DFA −
M=(Q, Σ, δ,q0,F)
Where,
- Q : Finite set called states.
- Σ : Finite set called alphabets.
- δ : Q × Σ → Q is the transition function.
- q0 ϵ Q is the start or initial state.
- F : Final or accept state.
NFA
NFA also has five states same as DFA, but with different transition function, as shown follows −
δ: Q X Σ → 2Q
Where,
- Q : Finite set of states
- Σ : Finite set of the input symbol
- q0 : Initial state
- F : Final state
- δ : Transition function
Differences
The major differences between the DFA and the NFA are as follows −
Deterministic Finite Automata | Non-Deterministic Finite Automata |
---|---|
Each transition leads to exactly one state called as deterministic | A transition leads to a subset of states i.e. some transitions can be non-deterministic. |
Accepts input if the last state is in Final | Accepts input if one of the last states is in Final. |
Backtracking is allowed in DFA. | Backtracking is not always possible. |
Requires more space. | Requires less space. |
Empty string transitions are not seen in DFA. | Permits empty string transition. |
For a given state, on a given input we reach a deterministic and unique state. | For a given state, on a given input we reach more than one state. |
DFA is a subset of NFA. | Need to convert NFA to DFA in the design of a compiler. |
δ : Q × Σ → Q For example − δ(q0,a)={q1} | δ : Q × Σ → 2Q For example − δ(q0,a)={q1,q2} |
DFA is more difficult to construct. | NFA is easier to construct. |
DFA is understood as one machine. | NFA is understood as multiple small machines computing at the same time. |
![]() | ![]() |
Advertisements