Average case unsuccessful find / insertion cost
-
Assume a table with load factor
α
= N/M. Consider random hashing, so clustering is not a problem; each probe location is generated randomly, and independently
-
With each probe, the probability of finding an empty location is (1-
α
). Finding an empty location stops the find or insertion
-
This is a Bernoulli process, with probability of success (1-
α
). The expected first-order interarrival time of such a process is 1/(1-
α
). So:
-
The average number of probes for insert or unsuccessful find with random hashing is
-
With linear probing, probe locations are not independent; clusters form, which leads to long probe sequences when load factor is high. It can be shown that the average number of probes for insert or unsuccessful find with linear probing is approximately
-
These average case time costs are bad, bounded only by M, when
α
is close to 1; but are not too bad (4 and 8.5 respectively) when
α
is .75 or less, independent of M
CONTENTS PREVIOUS NEXT