next up previous index
Next: Success Up: Collision resolution Previous: Clustering   Index


Quadratic probing

An alternative to linear probing is quadratic probing. Here we still explore a sequence of locations until an empty one is found, but instead of exploring

h, h+1, h+2, h+3, h+4, ...
we explore
h, h+1, h+4, h+9, h+16, ...
Instead of incrementing the offset by 1 each time, we increment it by 1,3,5,7,..., i.e. the differences between successive squares, always remembering that these increments are to be taken modulo table.length. Naturally other functions than the quadratic could be chosen, but this approach has negligible overhead compared with linear probing, and guarantees successful insertion, provided mild conditions are satisfied.



Subsections

Peter Williams 2005-06-07