4 ms·
If the original hash function is f(x), are there reasons the "second" hash function shouldn't be (f(x)+1)mod n (n being the number of hash slots)? I'm sure tha
by thyrsus 15y ago
If the original hash function is f(x), are there reasons the "second" hash function shouldn't be (f(x)+1)mod n (n being the number of hash slots)? I'm sure that some distribution of x would generate pathological behavior, but my question is whether it breaks the reasoning about the probabilities.
I'm trying to convince myself that a "second" hash function might be a reasonable cost even for modest n (e.g., when, as in perl, you use hashes to hold the attributes of an object, and the number of attributes will rarely exceed 50).
- andylei 15y agoyou want two items that have the same result from the first hash function to have different results from the second hash function, with relatively high probability. if f1(x0) = f1(x1), you don't want f2(x0) = f2(x1) to happen very much.