Due December 15, 10 points.
For this assignment you will write and test a KMP string matcher. Your code should be similar to the code in the Cormen, Leiserson, Rivest, and Stein textbook "Introductuction to Algorithms", 3rd edition, pp. 1005-1006. This code should be modified to implement an iterator interface as described in the TextBookKMPMatcher javadoc.
The project contains the file kmp.KMPMatcher.java, which is identical to TextBookKMPMatcher except for the class name. The code is designed for array indexing that starts at 1, so it does not work in java. You will need to modify the use of indexes, including character string indices, so that it works with indexing starting at 0.
In addition you should write a main program for testing your matcher. You should be able to demonstrate correct operation on the following pairs of strings:
Pattern | Text |
---|---|
ab | abbbbabbabab |
abac | abacabadabacabaeabacabadabacabaf |
aaaaaa | aaaaaaaaaaa |
ababababab | ababababaababababbababababababab |
Finally, your test program should print out the prefix function for all of the above patterns.
You should turn in a copy of your code for all of your classes. These classes should have your name included in comments. You should also turn in a modified script of the program execution. You can turn in the code and script in lab or submit them by web drop.
Section overview text.