- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Can we convert a non-deterministic finite automata into a deterministic finite Automata?

Yes, we can convert a NFA into DFA. For every NFA there exists an equivalent DFA. The equivalence is defined in terms of languages acceptance. Since NFA is nothing but a finite automata in which zero, one or more transitions on an input symbols are permitted. It can always construct finite automata which will simulate all moves of DFA on a particular input symbol in parallel, then get a finite automata in which there will be exactly one transition on every input symbol. Here, corresponding to a NFA there exist a DFA. To construct DFA equivalent to NFA, it should be remembered that states of DFA are a collection of states of NFA.

## Algorithm NFA – to – DFA

**Input** − NFA with set of states N = {n_{0},n_{1}……n_{n}}, with start state n_{0}.

**Output** − DFA, with set of states D′={d_{0},d_{1},d_{2}……d_{n}}, with start state d_{0}.

d_{0}=ε−closure (n_{0})

D′={d_{0}}

set d_{0} unmarked

while there is an unmarked state d in D′. { set d marked { For each input symbol 'a' { Let T be a set of states in NFA to which there is a transition on 'a' from some state ni in d d′=ε−closure (T). If d′ is not already present in D′ { D′=D′∪{d′} Add transition d→d′,labeled 'a' set d′ unmarked } } } }

**Example** − Design Lexical Analyzer for the following LEX Program.

AUXILIARY DEFINITION S letter = A|B|C|…….|Z digit = 0 |1|2|………|9 TRANSLATION RULES begin {return 1} end {return 2} If {return 3} then {return 4} else {return 5} letter (letter+digit)* {value=Install ( );return 6} digit + {value=Install ( );return 7} < {value=1;return 8} <= {value=2;return 8} = {value=3;return 8} < > {value=4;return 8} > {value=5;return 8} >= {value=6;return 8}

**Solution**

- The combined NFA for various patterns will be

**Convert NFA to DFA**− The corresponding DFA will be.

States {0, 1, 7, 11, 14, 19, 24, 26, 28, 30, 33, 35, 38, 40} are combined and named as q0to make a starting state of DFA.

In combined NFA, transitions from state 1 to 2 and from state 24 to 25 are the same because Input 'b' is a letter.

States 2, 25 are combined. Similarly, other states are combined.

States 29, 31 & 36 are combined because they all reach after getting the input '<'.

Similarly, other states are combined.

- Related Questions & Answers
- What is Non deterministic finite automata?
- Explain Non-Deterministic Finite Automata in TOC.
- What is Non-Deterministic Finite Automata (NFA)?
- Explain Deterministic Finite Automata in TOC.
- What is Deterministic Finite Automata (DFA)?
- Explain non-deterministic push down automata in TOC?
- What is finite automata?
- How to convert the finite automata into regular expressions?
- Efficient Construction of Finite Automata
- How to convert Regular expression to Finite Automata?
- Design finite automata from a given regular expression.
- Explain if the CFG is recognized by Non-deterministic push down automata
- What are different types of finite automata?
- Distinguish between Finite Automata and Turing Machine
- What is Finite Automata in Compiler Design?