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 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 DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CSC 30155 Wednesday 10/11/10 Dr. Daniel Hughes [email protected] The Plan for Today l Final Year Project Assignment 2: Project Design (20 mins) l KMP Pattern Matching Part 2 (20 mins) l Exam Question on KMP (20 mins) l Free Time to Work on the Tutorial Assignment (30 mins) Supporting Reading l Optional reading: l Cormen et al., Introduction to Algorithms , MIT Press, 2001, Chapter 32.4. Notes l I will pass around a conference volunteer sheet , please complete it and pass it back to me at the end of the class. l Everyone who volunteers will get a free lunch on both days as well as an official letter of thanks that can be mentioned in their CV. l While I encourage you to volunteer, it is not compulsory . CSC 30155 KnuthMorris Pratt Pattern Matching Dr. Daniel Hughes [email protected] KnuthMorrisPratt (KMP) l KMP uses an auxiliary function π defined over the states of the automaton. π can be computing in O(m) time. l π (q) gives us the information needed to quickly compute δ (q,x) = σ (P q x) for any x ∈ A l π [q] = max{k: P k is a proper suffix of P q } Prefix Function l The prefix function for a pattern P, is the function π : {1, … , m} à {0, … , m1} such that: π [q] = max{k: P k is a proper suffix of P q } l Example: Let P = 113 111 513 113. The corresponding prefix function is: l To define π [q] for q = 6 we consider P q ≡ 113 111, and then all prefixes P q1 , P q2 , … , ε , we find out that P 2 ( ≡ 11) is a suffix of P q . Hence π [6] = 2. Prefix Function l The prefix function for a pattern P, is the function π : {1, … , m} à {0, … , m1} such that: π [q] = max{k: P k is a proper suffix of P q } l Example: Let P = 113 111 513 113. The corresponding prefix function is: l To define π [q] for q = 6 we consider P q ≡ 113 111, and then all prefixes P q1 , P q2 , … , ε , we find out that P 2 ( ≡ 11) is a suffix of P q . Hence π [6] = 2. Prefix Function l The prefix function for a pattern P, is the function π : {1, … , m} à {0, … , m1} such that: π [q] = max{k: P k is a proper suffix of P q } l Example: Let P = 113 111 513 113. The corresponding prefix function is: l To define π [q] for q = 6 we consider P q ≡ 113 111, and then all prefixes P q1 , P q2 , … , ε , we find out that P 2 ( ≡ 11) is a suffix of P q . Hence π [6] = 2. Prefix Function l The prefix function for a pattern P, is the function π : {1, … , m} à {0, … , m1} such that: π [q] = max{k: P k is a proper suffix of P q } l Example: Let P = 113 111 513 113. The corresponding prefix function is: l To define π [q] for q = 6 we consider P q ≡ 113 111, and then all prefixes P q1 , P q2 , … , ε , we find out that P 2 ( ≡ 11) is a suffix of P q . Hence π [6] = 2. Prefix Function l The prefix function for a pattern P, is the function...
View
Full
Document
This note was uploaded on 05/22/2011 for the course CSC 30155 taught by Professor Garyli during the Spring '11 term at University of Liverpool.
 Spring '11
 GaryLi
 Databases

Click to edit the document details