Presentation is loading. Please wait.

Presentation is loading. Please wait.

Waseem Besada1 DFA vs NFA Deterministic Finite Automata Characterized as 5-tuple S is the set of states A is the alphabet T is the transition function:

Similar presentations


Presentation on theme: "Waseem Besada1 DFA vs NFA Deterministic Finite Automata Characterized as 5-tuple S is the set of states A is the alphabet T is the transition function:"— Presentation transcript:

1 Waseem Besada1 DFA vs NFA Deterministic Finite Automata Characterized as 5-tuple S is the set of states A is the alphabet T is the transition function: S x A S s 0 is the start state F is the set of accepting states. Characterized as 5-tuple S is the set of states A is the alphabet P T is the transition function: S x (A { }) P S s 0 is the start state F is the set of accepting states. Non-Deterministic Finite Automata

2 Waseem Besada2 From NFA To DFA 0 1 2 4 3 a a b a Tab 0 {1}ø {3} 1 ø {2} ø 2 ø ø ø 3 {3} ø {4} 4 {2} ø ø Transition function for NFA

3 Waseem Besada3 Calculating The Transition function for DFA Tab 0 {1}ø {3} 1 ø {2} ø 2 ø ø ø 3 {3} ø {4} 4 {2} ø ø T a b {0,3,4} ? ? Transition function for DFA T D ({0,3,4},a) = ({0},a) ({3},a) ({4},a) = {1,3} {3,4} {2} = {1,2,3,4} T D ({0,3,4},b) = ({0},b) ({3},b) ({4},b) = ø ø ø = ø Transition function for NFA

4 Waseem Besada4 Calculating The Transition function for DFA (forts) Tab 0 {1}ø {3} 1 ø {2} ø 2 ø ø ø 3 {3} ø {4} 4 {2} ø ø T a b {0,3,4} {1,2,3,4} ø Transition function for DFA ø ? ? {1,2,3,4} ? ? øø T D ({1,2,3,4},a) = ({1},a) ({2},a) ({3},a) ({2},a) = ø ø {3,4} {2} = {2,3,4} Similarly, T D ({1,2,3,4},b) = {2} {2,3,4}{2} Transition function for NFA

5 Waseem Besada5 Calculating The Transition function for DFA (forts) Tab 0 {1}ø {3} 1 ø {2} ø 2 ø ø ø 3 {3} ø {4} 4 {2} ø ø T a b {0,3,4} {1,2,3,4} ø Transition function for DFA ø ø ø {1,2,3,4} {2,3,4} {2} {2,3,4} {2,3,4} {2} {2} ø ø Transition function for NFA

6 Waseem Besada6 Finally T a b {0,3,4} {1,2,3,4} ø Transition function for DFA ø ? ? {1,2,3,4} {2,3,4} {2} øø {2,3,4} {2,3,4} {2} {2} ø ø 0123401234 0 2 4 3 1 b a,b b a a b a

7 Waseem Besada7 Exercise 2, solution 2. Construct directly (that is dont use the transformation procedure given in the lecture) a DFA for each of the following REs. a) a | b b) a | b* c) ab* | bc* a b a,b a b a b a b a,c a,b a,b,c c b a) b) c) c

8 Waseem Besada8 Exercise 4, solution 4. Construct directly (that is dont use the transformation procedure given in the lecture) a NFA for each of the following REs. a) a*bc*| bc b) a* | ab a c a b c a b a a) b)

9 Waseem Besada9 Exercise 5 5. Construct a DFA table for the following NFA transition table. The start state is 0 and there is one accepting state, 2. a b 0 Ø {1,2} {1} 1 {2} Ø Ø 2 Ø {2} {1} 1 0 2 a b b b

10 Waseem Besada10 Solution to exercise 5 a b 0 Ø {1,2} {1} 1 {2} Ø Ø 2 Ø {2} {1} T a b {0,1} ? ?{1,2} NFA transition table DFA transition table 0 1 0 1 a,b

11 Waseem Besada11 Exercise 6 6. Consider the following NFA over the alphabet {a,b}: a) Find a regular expression for the language accepted by the NFA. b) Write down the transition table for the NFA. c) Transform the NFA into a DFA d) Draw a picture of the resulting DFA. 00 0 a b a

12 Waseem Besada12 Solution to exercise 6 (contd) 01 2 a b a Transition table for NFA Tab 0 {1}Ø {1,2} 1 Ø {2} Ø 2{2} Ø Ø

13 Waseem Besada13 Solution to exercise 6 (contd) T ab 0 {1}Ø {1,2} 1 Ø {2} Ø 2 {2} Ø Ø Transition table for NFA T a b {0,1,2} {1,2}{2} {1,2} {2} {2} {2} {2} Ø Ø Ø Ø Transition table for DFA

14 Waseem Besada14 Solution to exercise 6(contd) T a b {0,1,2} {1,2}{2} {1,2} {2} {2} {2} {2} Ø Ø Ø Ø Transition table for DFA {0,1,2} {1,2} {2} a b a,b a

15 Waseem Besada15 Exercise 7 7. Transform each of the following REs into a NFA, then into a DFA a) a*b*b) a* | b*c) (a|b)* Solution to a) 01 23 45 6 a b 610 ab

16 Waseem Besada16 Solution, exercise 6-a 3 210 ab T ab {0,1,2,3} {1,2,3} {2,3} {1,2,3} {1,2,3} {2,3} {2,3} Ø {2,3} Ø Ø Ø 0 1 2 3 a b b a b a a,b 0 2 3 b a a b Can be reduced to:

17 Waseem Besada17 What to do next? It is your turn to solve the rest of the exercises


Download ppt "Waseem Besada1 DFA vs NFA Deterministic Finite Automata Characterized as 5-tuple S is the set of states A is the alphabet T is the transition function:"

Similar presentations


Ads by Google