This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Solution type 2 (specific) For example, the string x is ababab, the pattern is c, so f(1)=0, g(1)=0, in this case, if we use naive algorithm, we need 6 times comparing, and if we use KMP algorithm, we need 6 times comparing and 1 time computing for g(1), so the total time is O(m+n)=6+1=7, it is greater than naive algorithm which is O(mn)=6. 4. a. Consider a tree 1 / \ 2 3 / | \ | 4 5 6 7...
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