next up previous
Next: Up: Previous:

Analysis

Thus, for all buckets,

\begin{displaymath}\sum_{i=0}^{n-1} O(E(n_i^2)) \;=\; O(\sum_{i=0}^{n-1} E(n_i^2)).\end{displaymath}



Given:



What is the probability that an element will be inserted into some bucket i?

Answer: p = 1/n.



Given n trials consisting of putting elements into buckets, how many elements will be inserted into bucket i?

ni = Binomial(n,p)
with mean E(ni) = np = 1
and variance Var(ni) = np(1-p) = 1 - 1/n
E(ni2) = 1 - 1/n + 12
= 2 - 1/n
= $\Theta(1)$



Therefore, TIS = $\Theta(1)$
and
TBS = 4n + $\Theta(1)$n + 3 = O(n) for the average case. In the worst case, the run time is n2.


next up previous
Next: Up: Previous: