This preview shows pages 1–6. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Outline KnuthMorrisPratt Algorithm: an O ( m + n ) string matching algorithm. Suffix Trees: a type of data structures to answer string matching queries. Lecture 20, KMP Algorithm and Suffix Trees p. 1 Build a DFA manually Define states One initial state At least one accept state Define transitions between states Lecture 20, KMP Algorithm and Suffix Trees p. 2 A String Matching Example T = aaaaaaaaaaaaaaaaaaa P = aaab Using the naive algorithm A lot of unnecessary comparisons are made, since the answer has been known before the comparison How to improve? Build a more efficient DFA By KMP algorithm (coming next) Lecture 20, KMP Algorithm and Suffix Trees p. 3 Example (cont.) the smarter DFA Lecture 20, KMP Algorithm and Suffix Trees p. 4 KnuthMorrisPratt (KMP) Algorithm Phase I: building the DFA computing the prefix function Algorithm: ComputePrefixFunction( P [1 ..m ]) m length [ P ] [1] k for q 2 to m while k > 0 and...
View
Full
Document
This note was uploaded on 07/17/2010 for the course CS 240 taught by Professor Ortiz during the Spring '09 term at Waterloo.
 Spring '09
 ORTIZ
 Data Structures

Click to edit the document details