News Score: Score the News, Sort the News, Rewrite the Headlines

How fast is rolling Karp-Rabin hashing?

A hash function maps values (e.g., strings) into a fixed number of strings, typically smaller than the original. It is useful to compare quickly two long strings, for example. Instead of comparing the strings, you may compare the hash values. A simple hash function consists in repeatedly multiplying the hash value by some constant B (e.g., you may pick a number such as 31): uint32_t hash = 0; for (size_t i = 0; i < len; i++) { hash = hash * B + data[i]; } return hash; I credit Karp-Rabin for thi...

Read more at lemire.me

© News Score  score the news, sort the news, rewrite the headlines