Rolling hash, which method to use?

Revision en2, by qwi, 2021-08-16 20:11:16

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!

Tags rolling hashes, string hash

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English qwi 2021-08-16 20:11:16 200 Tiny change: 'lling hashes: dacin21'' -> 'lling hash: dacin21'' (published)
en1 English qwi 2021-08-16 20:06:18 780 Initial revision (saved to drafts)