Hash Crash Revolutions

Suppose our hash table has 1 0 3 10^3 slots. Under the simple uniform hashing assumption, what is the expected number of distinct elements that needs to be inserted into the table so that all of the slots are occupied by at least one element?


This problem is a part of the Hash Crash Series


The answer is 7485.470860550345.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Abhishek Sinha
Jul 10, 2016

Relevant wiki: Coupon Collector Problem

Assume that we have a total of n n slots, of which m 1 m-1 distinct slots are occupied. Then let's first compute the number of additional elements that need to be inserted so that m m distinct slots are occupied. Clearly, the probability that a newly inserted element occupies a previously unoccupied slot is p succ ( m ) = n m + 1 n p_{\text{succ}}(m)=\frac{n-m+1}{n} . Hence we need 1 p succ ( m ) = n n m + 1 \frac{1}{p_{\text{succ}}(m)}=\frac{n}{n-m+1} additional element, in expectation, for the required transition. As a result, total number of elements N N required, in expectation to fill up the entire Hash table is N = m = 1 n n n m + 1 = n H n , N=\sum_{m=1}^{n}\frac{n}{n-m+1}=nH_n, where H n H_n is the n n th harmonic number, which may be readily computed.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...