------------------------------------------------------------------------------
COMP 731 - Data Struc & Algorithms - Lecture 30 - Friday, September 15, 2000
------------------------------------------------------------------------------
Today:
o KMP algorithm
Follow the presentation approach of
Dan Gusfield/Chip Martel in which one starts
with a FA for the language and simplifies it:
one new state, -1, rest of states, 0 ..., m, as before.
Then add a back arc to just before the
closest state to which there was a back-arc. No label for this arc.
Call this the "failure arrow".
Show how to run this machine, and informally describe why it works.
Show the array-representation of the failure function and how to run
the algorithm under that representation, using two variables,
i (into text T) and j (into pattern P)
Claim a time bounds of O(m) for cleverly constructing the failure table,
though all we will have seen is O(m^2 |Sigma|).
Prove a time bound of O(n) for running the KMP algorithm, using the
following idea:
Total amount of "steps" (moves left or right) =
Total amount of steps right +
Total amount of steps left.
First is <= n, second is <= first, so total is <= 2n. O(n) time.
Let the kids go 10 mins early!