lec20

# lec20 - Outline Knuth-Morris-Pratt Algorithm: an O ( m + n...

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 Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Outline Knuth-Morris-Pratt 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 Knuth-Morris-Pratt (KMP) Algorithm Phase I: building the DFA computing the prefix function Algorithm: Compute-Prefix-Function( 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.

### Page1 / 11

lec20 - Outline Knuth-Morris-Pratt Algorithm: an O ( m + n...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online