

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The construction and correctness of a deterministic finite automaton (dfa) for string matching. The dfa is used to identify the presence of a given pattern in a text string. The general construction scheme, including the final state function and suffix function, as well as the dfa-based matching algorithm. The time and space complexity of the algorithm are also discussed.
Typology: Study notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


DFA for String matching
Finite Automaton
General Construction Scheme
Final state function : (w) is the state after scanning w.
Suffix function : (x) = max {k: P[1 โฆ k ] is a suffix of x}.
Construction: Q = {0, 1, โฆ , m}, q 0 = 0, A = {m}, (q, a) = (P (^) q a).
DFA-based Matching
FA-Matcher(T, , m)
This takes (n) time and (m | |) space.
Correctness of Construction
We wish to prove that the state is (T (^) i) after scanning T[1 โฆ i]. That is, we wish to prove that ( T (^) i) = (T (^) i).
Theorem 32.4: ( T (^) i) = (T (^) i), i = 0, โฆ, n. Proof: We prove the theorem by induction on i.
Base case: ( T 0 ) = 0 = (T 0 ). Induction hypothesis: Assume (T (^) i) = (T (^) i).
We wish to prove that ( T (^) i+1 ) = (T (^) i+1).
( T (^) i+1 ) = ( T (^) i T[i+1]) = ( ( T (^) i), T[i+1]) (from the definition of ) = (P (Ti) T[i+1]) (from the definition of ) = (P (Ti) T[i+1]) (from the induction hypothesis) = (T (^) i T[i+1]) (from lemma 32.3) = (T (^) i+1). Q.E.D.
Constructing
This takes O( m^3 | |) time. This can be improved to O( m | |).