SlideServe
Menu
Préférences
© SlideServe · v2026

DFA vs NFA

deirdre-lane avatar
17 diapositives · 1.3K Views · Nov 08, 2014

DFA vs NFA. Deterministic Finite Automata. Non-Deterministic Finite Automata. Characterized as 5-tuple < S, A, T, s 0 , F > 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.

DFA vs NFA - slide 1
01 / 17DFA vs NFA
1 / 17

Télécharger la présentation

DFA vs NFA
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. DFA vs NFA Deterministic Finite Automata Non-Deterministic Finite Automata • Characterized as 5-tuple < S, A, T, s0, F > • S is the set of states • A is the alphabet • T is the transition function: S x A  S • s0 is the start state • F is the set of accepting states. • Characterized as 5-tuple < S, A, T, s0, F > • S is the set of states • A is the alphabet • T is the transition function: S x (A{}) PS • s0 is the start state • F is the set of accepting states. Waseem Besada

  2. From NFA To DFA 1 Transition function for NFA b a 2 T a b  0 0 {1} ø {3} a 1 ø {2} ø  2 ø ø ø 3 {3} ø {4}  4 3 a 4 {2} ø ø Waseem Besada

  3. Calculating The Transition function for DFA Transition function for NFA Transition function for DFA T a b  T a b 0 {1} ø {3} {0,3,4} ? ? 1 ø {2} ø TD({0,3,4},a) = ({0},a)  ({3},a)  ({4},a) = {1,3}  {3,4}  {2} = {1,2,3,4} 2 ø ø ø 3 {3} ø {4} TD({0,3,4},b) = ({0},b)  ({3},b)  ({4},b) = ø  ø  ø = ø 4 {2} ø ø Waseem Besada

  4. Calculating The Transition function for DFA (forts) Transition function for DFA Transition function for NFA T a b T a b  {0,3,4} {1,2,3,4} ø 0 {1} ø {3} ø ? ? 1 ø {2} ø ø ø {1,2,3,4} ? ? 2 ø ø ø {2,3,4} {2} 3 {3} ø {4} TD({1,2,3,4},a) = ({1},a)  ({2},a)  ({3},a)  ({2},a) = ø  ø  {3,4}  {2} = {2,3,4} Similarly, TD({1,2,3,4},b) = {2} 4 {2} ø ø Waseem Besada

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

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

  7. Exercise 2, solution 2. Construct directly (that is don’t 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* b a a,b a,b a a,c a,b,c b a,b a a,b b a,b a,b c a) b c c) a b) b Waseem Besada

  8. Exercise 4, solution 4. Construct directly (that is don’t 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  a c a b b) a) Waseem Besada

  9. 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}  b 1 0  a b 2 b Waseem Besada

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

  11. 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. a  b 0 0 0 a  Waseem Besada

  12. Solution to exercise 6 (cont’d) Transition table for NFA T a b  0 {1}Ø {1,2} 1 Ø {2} Ø 2 {2} Ø Ø a  b 0 1 2 a  Waseem Besada

  13. Solution to exercise 6 (cont’d) Transition table for NFA Transition table for DFA T a b {0,1,2} {1,2}{2} {1,2} {2} {2} {2} {2} Ø Ø Ø Ø T a b  0 {1}Ø {1,2} 1 Ø {2} Ø 2 {2} Ø Ø Waseem Besada

  14. Solution to exercise 6(cont’d) {0,1,2} Transition table for DFA a {1,2} T a b {0,1,2} {1,2}{2} {1,2} {2} {2} {2} {2} Ø Ø Ø Ø b a,b {2} a Waseem Besada

  15. 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)  a b a      2 3   0 1 6 6 0 1   b 4 5  Waseem Besada

  16. Solution, exercise 6-a T a b {0,1,2,3} {1,2,3} {2,3} {1,2,3} {1,2,3} {2,3} {2,3} Ø {2,3} Ø Ø Ø a b    0 1 2 3 a a Can be reduced to: 0 a a,b 1 b a 0 b a,b 2 3 b a 2 3 b b Waseem Besada

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