O slideshow foi denunciado.
Seu SlideShare está sendo baixado. ×
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio

Confira estes a seguir

1 de 22 Anúncio

Mais Conteúdo rRelacionado

Semelhante a NFA & DFA (20)

Anúncio

Mais de Akhil Kaushik (20)

Mais recentes (20)

Anúncio

NFA & DFA

  1. 1. Akhil Kaushik Asstt. Prof., CE Deptt., TIT Bhiwani NFA & DFA
  2. 2. Regular Expression • letter = [a –z] or [A –Z] • digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 or [0-9] • sign = [ + | -] • Decimal = (sign)?(digit)+ • Identifier = (letter)(letter | digit)* • Float = (sign)? (digit) +.+ (digit)*
  3. 3. Finite State Automata (FSA)
  4. 4. Finite State Automata (FSA) • There are two main kinds of FSA:- – Non-Deterministic Finite Automata (NFA): at a particular state, a unique path may not be determined for each input alphabet. – Deterministic Finite Automata (DFA): at a particular state, a unique path determined for each input alphabet.
  5. 5. Finite State Automata (FSA) • For every non-deterministic automata, there is an equivalent deterministic automata. • The below NFA is equivalent to the regular expression/ab*ca?/.
  6. 6. NFA • In a NFA, for each state there can be zero, one, two, or more transitions corresponding to a particular symbol. • For a particular input symbol, the machine can move to any combination of the states in the machine. Hence, it is called NFA. • Only NFA state automaton can have an ε transition. • The procedure is like: RE → NFA → DFA → Tables
  7. 7. NFA An NFA can be represented by a 5-tuple (Q, Σ, δ, q0, F) where:− • Q is a finite set of states. • Σ is a finite set of symbols called the alphabets. • δ is the transition function where δ: Q × Σ → 2Q • q0 is the initial state & F is the final state (Here the power set of Q (2Q) has been taken because in case of NFA, from a state, transition can occur to any combination of Q states)
  8. 8. NFA – State Digrams • Represented by digraphs called state diagram: used to graphically represent finite state machines to give an abstract description of the behavior of a system.
  9. 9. NFA Examples
  10. 10. NFA Examples 00 (0 + 1)*
  11. 11. DFA • In DFA, for each input symbol, one can determine the state to which the machine will move. Hence, it is called Deterministic Automaton. • As it has a finite number of states, the machine is called Deterministic Finite Machine. • Q is a finite set of states. • Σ is a finite set of symbols called the alphabet. • δ is the transition function where δ: Q × Σ → Q
  12. 12. NFA vs DFA • In NFA each pair of state and input symbol can have many possible next states. • NFA can use empty string transition. • NFA is easier to construct. • NFA requires less space. • In DFA the next possible state is distinctly set. • DFA cannot use empty string transition. • It is more difficult to construct DFA. • DFA requires more space.
  13. 13. NFA to DFA
  14. 14. NFA to DFA
  15. 15. NFA to DFA
  16. 16. NFA to DFA
  17. 17. NFA to DFA
  18. 18. NFA to DFA
  19. 19. NFA to DFA
  20. 20. Transition Table of DFA
  21. 21. DFA Minimization • Make a partition of final & non-final states: • T = { {E}, {A, B, C, D} } • T = { {E}, {A, B, C}, {D} } • T = { {E}, {A, C}, {B}, {D} } or • T = { {E}, {A1}, {B}, {D} }
  22. 22. Akhil Kaushik akhilkaushik05@gmail.com 9416910303 CONTACT ME AT: Akhil Kaushik akhilkaushik05@gmail.com 9416910303 THANK YOU !!!

×