Randomized Hashing
Despite our best efforts, it’s still possible to have a data set in which a given hash function will not distribute the data with ideal uniformity. Let’s look at some examples.
Example 1: If M is 11, and our data is [55, 22, 99, 88, 11, 66, 44, 77, 33], all the data will end up at the array’s index 0 since all these integers of our data set are divisible by 11. We’ve mentioned that uniformity gets messed up when the data set and M are both divisible by a common third number. However, it’s also problematic if all the data is divisible by M itself.
Example 2: Let’s keep M at 11, but use the data set of [56, 23, 100, 89, 12, 67, 45, 78, 34]. This data set is the data set from Example 1, except that each integer has been increased ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access