NFA to DFA Conversion
Afsana Afrin
Lecturer
Dept of Computer Science and Engineering
Bangladesh Army University of Science & Technology
12-Jul-20 NFA to DFA Conversion 1
NFA to DFA Conversion
Let X = (Qx, ∑, δx, q0, Fx) be an NFA which accepts the language
L(X). We have to design an equivalent DFA Y = (Qy, ∑, δy, q0, Fy)
such that L(Y) = L(X). The following procedure converts the NFA
to its equivalent DFA −
Algorithm
Input − An NFA
Output − An equivalent DFA
12-Jul-20 NFA to DFA Conversion 2
NFA to DFA Conversion
Step 1 − Create state table from the given NFA.
Step 2 − Create a blank state table under possible input alphabets
for the equivalent DFA.
Step 3 − Mark the start state of the DFA by q0 (Same as the NFA).
Step 4 − Find out the combination of States {Q0, Q1,... , Qn} for
each possible input alphabet.
Step 5 − Each time we generate a new DFA state under the input
alphabet columns, we have to apply step 4 again, otherwise go to
step 6.
Step 6 − The states which contain any of the final states of the
NFA are the final states of the equivalent DFA.
12-Jul-20 NFA to DFA Conversion 3
Example
Convert the given NFA to DFA.
12-Jul-20 NFA to DFA Conversion 4
Example
Solution: For the given transition diagram we will first
construct the transition table.
0 1
→q0 {q0} {q1}
q1 {q1, q2} {q1}
*q2 {q2} {q1, q2}
12-Jul-20 NFA to DFA Conversion 5
Solution
Now we will obtain δ transition for state q0.
δ({q0}, 0) = {q0}
δ({q0}, 1) = {q1}
The δ transition for state q1 is obtained as:
δ({q1}, 0) = {q1, q2} (new state generated)
δ({q1}, 1) = {q1}
12-Jul-20 NFA to DFA Conversion 6
Solution
Now we will obtain δ transition on {q1, q2}.
δ({q1, q2}, 0) = δ(q1, 0) ∪ δ(q2, 0)
= {q1, q2} ∪ {q2}
= {q1, q2}
δ({q1, q2}, 1) = δ(q1, 1) ∪ δ(q2, 1)
= {q1} ∪ {q1, q2}
= {q1, q2}
12-Jul-20 NFA to DFA Conversion 7
Solution
0 1
→{q0} {q0} {q1}
{q1} {q1, q2} {q1}
*{q1,q2} {q1,q2} {q1, q2}
Figure: Transition Table
12-Jul-20 NFA to DFA Conversion 8
Solution
12-Jul-20 NFA to DFA Conversion 9
Thank You
12-Jul-20 NFA to DFA Conversion 10