πŸŽ“ Computer Science & Engineering Portal

Master Engineering Disciplines with Structured Notes

Comprehensive academic lecture notes, exam-oriented unit summaries, laboratory manuals, and previous year question papers designed strictly for university students.

πŸ“‘

University Syllabi

AKTU & AICTE aligned semester guidelines.

πŸ“

Exam Question Papers

Previous 5 years solved university papers.

πŸ’‘

Lab Manuals & Viva

Practical codes with outputs & interview Qs.

Core Subjects & Units Hub

Click on any specific unit to immediately view its lecture notes below

Viewing All Lectures

Conversion from NFA to DFA

Conversion from NFA to DFA

In NFA, when a specific input is given to the current state, the machine goes to multiple states. It can have zero, one or more than one move on a given input symbol. On the other hand, in DFA, when a specific input is given to the current state, the machine goes to only one state. DFA has only one move on a given input symbol.

Let, M = (Q, βˆ‘, Ξ΄, q0, F) is an NFA which accepts the language L(M). There should be equivalent DFA denoted by M' = (Q', βˆ‘', q0', Ξ΄', F') such that L(M) = L(M').

Steps for converting NFA to DFA:

Step 1: Initially Q' = Ο•

Step 2: Add q0 of NFA to Q'. Then find the transitions from this start state.

Step 3: In Q', find the possible set of states for each input symbol. If this set of states is not in Q', then add it to Q'.

Step 4: In DFA, the final state will be all the states which contain F(final states of NFA)

Example 1:

Convert the given NFA to DFA.

Conversion from NFA to DFA

Solution: For the given transition diagram we will first construct the transition table.

State

0

1

β†’q0

q0

q1

q1

{q1, q2}

q1

*q2

q2

{q1, q2}

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]  

The Ξ΄' transition for state q2 is obtained as:

Ξ΄'([q2], 0) = [q2]  

Ξ΄'([q2], 1) = [q1, q2]  

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}  

                      = [q1, q2]  

 

The state [q1, q2] is the final state as well because it contains a final state q2. The transition table for the constructed DFA will be:

State

0

1

β†’[q0]

[q0]

[q1]

[q1]

[q1, q2]

[q1]

*[q2]

[q2]

[q1, q2]

*[q1, q2]

[q1, q2]

[q1, q2]

The Transition diagram will be:


Conversion from NFA to DFA

The state q2 can be eliminated because q2 is an unreachable state.

Example 2:

Convert the given NFA to DFA.

Conversion from NFA to DFA

Solution: For the given transition diagram we will first construct the transition table.

State

0

1

β†’q0

{q0, q1}

{q1}

*q1

Ο•

{q0, q1}

Now we will obtain Ξ΄' transition for state q0.

Ξ΄'([q0], 0) = {q0, q1}  

               = [q0, q1]       (new state generated)  

Ξ΄'([q0], 1) = {q1} = [q1]  

The Ξ΄' transition for state q1 is obtained as:

Ξ΄'([q1], 0) = Ο•  

Ξ΄'([q1], 1) = [q0, q1]  

Now we will obtain Ξ΄' transition on [q0, q1].

Ξ΄'([q0, q1], 0) = Ξ΄(q0, 0) βˆͺ Ξ΄(q1, 0)  

                      = {q0, q1} βˆͺ Ο•  

                      = {q0, q1}  

                      = [q0, q1]  

 

Similarly,

Ξ΄'([q0, q1], 1) = Ξ΄(q0, 1) βˆͺ Ξ΄(q1, 1)  

                      = {q1} βˆͺ {q0, q1}  

                      = {q0, q1}  

                      = [q0, q1]  

 

As in the given NFA, q1 is a final state, then in DFA wherever, q1 exists that state becomes a final state. Hence in the DFA, final states are [q1] and [q0, q1]. Therefore set of final states F = {[q1], [q0, q1]}.

The transition table for the constructed DFA will be:

State

0

1

β†’[q0]

[q0, q1]

[q1]

*[q1]

Ο•

[q0, q1]

*[q0, q1]

[q0, q1]

[q0, q1]

The Transition diagram will be:

Conversion from NFA to DFA

Even we can change the name of the states of DFA.

Suppose

A = [q0]  

B = [q1]  

C = [q0, q1]  

With these new names the DFA will be as follows:

Conversion from NFA to DFA

Labels: ,

Discussion & Queries (<$I18NNumComments$>):

<$CommentPager$>
<$I18NAtCommentTimeWithPermalink$>, <$I18NCommentAuthorSaid$>

<$BlogCommentBody$>

<$BlogCommentDeleteIcon$>
<$CommentPager$>