2c03-review - 00099

2c03-review - 00099 - by procedure find1 (i.e. the...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CS2MD3. Sample solutions to the assignment 2. Total of this assignment is 122pts. Each assignment is worth 5%. If you think your solution has been marked wrongly, write a short memo stating where marking in wrong and what you think is right, and resubmit to me during class, office hours, or just slip under the door to my office. 1[20]. a[5]. Compute the failure function f for pat =abaabaabab 1 2 3 4 5 6 7 8 9 10 a b a a b a a b a b f(I) 0 0 1 1 2 3 4 5 6 2 b[15]. Suppose that x = abbbabbaabbabaababaabaabaababbabbbabba and we want to know if text x contains pattern pat. How many character comparisons are required
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: by procedure find1 (i.e. the straightforward algorithm)? How many character comparisons are required by procedure find2 (i.e. the KMP algorithm)? Using find 1 a b b b a b b a a b b a b a a b a b a a b a a b a a b a b b a b b b a b b a # pass1 a b a 3 pass2 a 1 pass3 a 1 pass4 a 1 pass5 a b a 3 pass6 a 1 pass7 a 1 pass8 a b 2 pass9 a b a 3 pass10 a 1 pass11 a 1 pass12 a b a a b a a 7 pass13 a 1 pass14 a b 2 pass15 a b a a 4 pass16 a 1 pass17 a b a a b a a b a b 10 pass18 a 1 pass19 a b 2 pass20 a b a a b a a b a b 10 56...
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.

Ask a homework question - tutors are online