|
|
|
|
|
The higher the load factor, the more likely we would need to search for an entry or an empty slot (for insertion)
# entries n Load factor a = ------------ = --- array size N |
# occupied entries Ҏ[ an array slot is occupied by an entry] = -------------------------- Total # entries in array n = --- N |
Conclusion:
|
Important fact from Theory of Probability:
|
Example:
|
|
|
|
|
Avg. # probes = (1 - a) × 1 + a(1 - a) × 2 + a2(1 - a) × 3 + ... = (1 - a) × ( 1 + a×2 + a2×3 + ... ) = (1 - a) × ( 1×a0 + 2×a1 + 3×a2 + 4×a3 + ... ) |
>> math In[0]:= Sum[ (k+1)*a^k, {k,0,Infinity} ] -2 -2 Out[0]= (-1 + a) = (1 - a) |
1 Avg. # slots probed (to find empty slot) = (1 - a) * ------- (1 - a)2 1 = ------- (1 - a) |
Graphically:
|
|
Note:
|
O( 1/(1 - a) ) ~= O(1) as long as a is small, (say < 0.5) |