Reputation: 111
In hashtable, let’s say that H0(x) = x mod m And if we say that to avoid collision, we use linear probing Hi(x) = (x + i) mod m
But whatever the hash function is, whether we do linear probing or quadratic probing, While searching for a key, it has to go through all the collisions right?
So the idea is like this : What about updating the hash function h(x) itself as If element a, after passing all the collisions, was placed in (H0(a) + La) mod m Then what about updating the hash function itself as H(x) = h0(x) + La*f(x-a) while f(x-a) is 1 only if x=a ? Then, when later searching for a, we dont have to go through all the collisions but just find the element rightaway..? What is the problem with this idea?
Upvotes: 1
Views: 66