Docsity

Algorithm analysis Design and Microprocessor - Finite Automata, Study notes of Design and Analysis of Algorithms

Partial preview of the text

Download Algorithm analysis Design and Microprocessor - Finite Automata and more Study notes Design and Analysis of Algorithms in PDF only on Docsity!

Finite Automata

Introductory Example

An automaton that accepts all legal Pascal identifiers: 1 2 3 Lette r Digit Letter or Digit Letter or Digit "yes" "no" 2

Operational Manner

Control unit q 0 Input file yes/no

Transition Graphs

M = (Q, , , q 0 , F)

  • (^) |Q| vertices (circles)
  • Edge (qi, qj) labelled a for (qi, a) = qj
  • (^) Initial vertice q 0
  • (^) Final vertices (double circles) in F

Extended Transition Function

(q 0 , a) = q 1 & (q 1 , b) = q 2  *(q 0 , ab) = q 2

Extended Transition Function

(q 0 , a) = q 1 & (q 1 , b) = q 2  (q 0 , ab) = q 2 (q, ) = q (q, wa) = ((q, w), a)

Example 1

M = ({q 0 , q 1 , q 2 }, {a, b}, , q 0 , {q 1 }) L(M) =? q 0 q 1 q 2 a, b a, b a b

Example 1

M = ({q 0 , q 1 , q 2 }, {a, b}, , q 0 , {q 1 }) L(M) = {anb | n  0} trap state q 0 q 1 q 2 a, b a, b a b

Example 2

L(M) = {w{a, b}*^ | w starts with ab}

Example 2

L(M) = {w{a, b}*^ | w starts with ab} q 0 q 1 q 2 b a, b b a q 3 trap state a a, b

Example 3

L(M) = {w{0, 1}*^ | w does not contain 001}  0 001 0 0, 1 1 1 00 0 1 0 trap state

Regular Languages

L is regular iff L = L(M) for some DFA M

Example 4

L = {awa | w{a, b}*} q 0 q 2 q 3 b a b a trap state q 1 a a, b b

Example 5

L = {awa | w{a, b}} L^2 = {aw 1 aaw 2 a | w 1 , w 2 {a, b}}