Search for question
Question

1. Describe the naive algorithm for string-matching. State its worst-case running time when looking for a pattern of length m in a string of length n.achieves an improvement on this.

[10 marks]Outline how the Rabin-Karp (rolling hash) algorithm 2. How would you extend the Rabin-Karp algorithm to compute the set of different strings of length m that occur in a string of length n? Give pseudocode. For example, the string gggggggttttt contains only the following substrings of length 3: ggg, ggt, gtt, and ttt. [5 marks]

Fig: 1

Fig: 2