2,008 views
3 votes
3 votes
Suppose we use hash function H(n) to hash n distinct element(keys) into an array T of length m. What is the expected number of colliding pairs of element, if we use simple uniform hashing?

1 Answer

Best answer
5 votes
5 votes

# of slots = m

# of keys = n

so Expected number of colliding pairs  // uniform hashing

We will consider all cases like a child(simplest way to calculate expected value) to know expectation

We know in uniform hashing the probability for any particular key to get any particular slot = 1/m

now to collide another element must have to allocate same slot , and we know Pthat slot =1/m

So let suppose your Key =Kso now total n-1 keys can make pair with it and collide so possible outcomes of this case = n-1 and P=1/m

Now when Key=K2 now possible keys that can collide are n-2

so in that way when key=Kn-1 the possible keys that cna collide =1 so 1 outcome of this case

so expected value = (n-1)*1/m + (n-2)*1/m + (n-3)*1/m +....2*1/m + 1*1/m

so it's     n*(n-1)/2m

You can know the proper process here , they just calculated final output of summation wrong , that's n-1 not n+1

https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-046j-introduction-to-algorithms-sma-5503-fall-2005/exams/final_sol.pdf

the approach i followed to calculate expected value

https://www.wikihow.com/Calculate-an-Expected-Value

selected by

Related questions

0 votes
0 votes
1 answer
1
tishhaagrawal asked Dec 16, 2023
355 views
Below is my approach to solving this question, can anyone please explain if I am doing it the right way?Let X = #free slotssince, m =7 and n = 3So, $4 \leqslant x\leqsla...
1 votes
1 votes
2 answers
3
anurag_am asked May 29, 2015
1,693 views
why in open address hash table with load factor α=n/m<1, the expected number of probes in an unsuccessful search is at most 1/(1-α) assuming uniform hashing ?
0 votes
0 votes
1 answer
4
anurag_am asked May 27, 2015
1,338 views
why in a hash table in which collisions are resolved by a chaining , a successful search takes average- case time ⊖(1+load factor) ,under the assumption of simple unifo...