Expected number of hash collisions

后端 未结 2 1763
死守一世寂寞
死守一世寂寞 2020-12-10 04:56

I feel like I\'m way overthinking this problem, but here goes anyway...

I have a hash table with M slots in its internal array. I need to insert N elements into the

相关标签:
2条回答
  • 2020-12-10 05:38

    The formula for the SUM(x*(x+1)/2) metric can be found here, and the expected value appears to be (n/2m)* (n+2m -1).

    Don't know about the variance, IANAM.

    0 讨论(0)
  • 2020-12-10 05:54

    You'll find the answer here: Quora.com. The expected number of collisions for m buckets and n inserts is

    n - m * (1 - ((m-1)/m)^n).

    0 讨论(0)
提交回复
热议问题