Linear probing: searching for a key
-
If keys are inserted in the table using linear probing, linear probing will find them!
-
When searching for a key K in a table of size N, with hash function H(K) :
1. Set indx = H(K)
2. If table location indx contains the key, return FOUND.
3. Else if table location indx is empty, return NOT FOUND.
4. Else set indx = (indx + 1) mod M.
5. If indx == H(K), return NOT FOUND. Else go to 2.
-
Question: How to delete a key from a table that is using linear probing?
-
Could you do "lazy deletion", and just mark the deleted key’s slot as empty? Why or why not?
CONTENTS PREVIOUS NEXT