Linear collision for closed hash table run out of space

451 views Asked by At

So I have an 8-bucket hash table with h(i) = i mod 8 These are the numbers being inserted:

7, 11, 18, 28, 20, 8, 15, 23

I just started learning hash table so I'm pretty confused about these concepts.

If I have an open hash table, the result would just be:

0 | 8
1 |
2 | 18
3 | 11
4 | 28 20
5 |
6 |
7 | 7 15 23

Now if I have to use a closed hash and implement linear collision handling, I would have

0 | 8
1 | 15 moved from 7
2 | 18
3 | 11
4 | 28 
5 | 20 moved from 4
6 | 23 moved from 7
7 | 7

Am I doing this right?

1

There are 1 answers

0
templatetypedef On BEST ANSWER

Yes, this looks correct. Note that in practice hash tables have a threshold load factor at which they'll perform a resize to keep the load factor low, so typically you wouldn't let the linear probing table fill up to the level you've demonstrated.