Search for question
Question

The lecture on Rabin-Karp string matching covered both the actual Java hash function and a strawman hash

function, where the hash value of a string is just the sum of the character values in the string. Assume that we

modified the Rabin-Karp string matching algorithm to use the strawman hash instead of the Java hash. (That

is, we change the mathematical expressions in the 'update' loop, and change the initial computations of

texthash and patternhash before the loop, but do not modifying any other part of the code.)

What would be the effect of this change?

Select one:

O a. It should work exactly as well

O b. It should have the same running speed, but it would no longer be guaranteed to be a correct pattern matching

algorithm

O c. It would still be a correct pattern matching algorithm, but it could be much slower on some data.

O d. Both problems could arise (worse running time and an incorrect algorithm)