qwi's blog

By qwi, history, 3 years ago, In English

Recently, I have been reading up on few blogs about rolling hash: dacin21's [On the mathematics behind rolling hashes and anti-hash tests] and rng_58's [Hashing and Probability of Collision]. Both of them showcase different hashing technique.

Method described in dacin21's blog:

Note: in the above equation a is the base

Method described in rng_58's blog:

H(a) = (r+a_1)(r+a_2)...(r+a_n)

Note: in the above equation r is the base

Are there any differences between the two in terms of use-case and other parameters? Which one do you recommend? Also, if possible can you please share your implementation of rolling hash if you have ever used it to solve any problem. Thanks!

  • Vote: I like it
  • +16
  • Vote: I do not like it

»
3 years ago, # |
  Vote: I like it +45 Vote: I do not like it

rng's method only applies to multisets, not strings. Don't use it for strings.