1

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?

JungIn Choi
  • 111
  • 2
  • `while f(x-a) is 1 only if x=a `. You'll need another Map to store this information (as well as `La`). Or you can literally create such function; then its computation time will be linear. –  Jun 01 '19 at 02:40
  • @dyukha ooh then it will be no use using hash table since its computation time wont be O(1).. – JungIn Choi Jun 01 '19 at 03:59

0 Answers0