This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Plenty of possible solutions, all rather straightforward implementation of the algorithm presented in class. 2.[20] a.[5] Compute the failure function f for pat = abbababaaabab 1 2 3 4 5 6 7 8 9 10 11 12 13 a b b a b a b a a a b a b f(i) 0 0 0 1 2 1 2 1 1 1 2 1 2 g(i) 0 1 1 1 2 3 2 3 2 2 2 3 2 b.[15] Suppose that x = abaababaababbababaaababaabaababb and we want to know if text x contains pattern pat. How many character comparisons are required by the straightforward algorithm? How many character comparisons are required by procedure the KMP algorithm? Using straightforward algorithm a b a A b a b a a b a b b a b a b a a a b a b a a b a b b # of comparisons pass1 a b b 3 pass2 a 1 pass3 a B 2 pass4 A b b 3 pass5 a 1 pass6 a b b 3 pass7 a 1 pass8 a b 2 pass9 a b b 3 pass10 a 1 pass11 a b b a b a b a a a b a b 13 Total 33...
View
Full
Document
This note was uploaded on 12/10/2009 for the course CAS 2c03 taught by Professor Janicki during the Spring '03 term at McMaster University.
 Spring '03
 janicki

Click to edit the document details