16_KMP_PatternMatching2

16_KMP_PatternMatching2 - CSC 30155 Wednesday Dr Daniel...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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 Knuth-Morris Pratt Pattern Matching Dr. Daniel Hughes [email protected] Knuth-Morris-Pratt (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, … , m-1} 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 q-1 , P q-2 , … , ε , 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, … , m-1} 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 q-1 , P q-2 , … , ε , 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, … , m-1} 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 q-1 , P q-2 , … , ε , 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, … , m-1} 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 q-1 , P q-2 , … , ε , 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.

Page1 / 46

16_KMP_PatternMatching2 - CSC 30155 Wednesday Dr Daniel...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online