retagged by
1,727 views
0 votes
0 votes
Consider a Hash table containing ‘n’ keys and ‘k’ slots. Each key will hash into a slot in the given Hash table. (Assume collisions are resolved by chaining).
1)What is the probability that the first slot of hash table will be empty?

 

2)What is the expected number of slots that are being nonempty?
retagged by

1 Answer

Best answer
1 votes
1 votes
I hope this helps.....
1)What is the probability that the first slot of hash table will be empty?

   => 1st element has the probability of getting a slot is 1/k . not getting a slot is (k-1)/k

     .: The probability that first slot being empty after n keys are hashed is (k-1)/k  *  (k-1)/k * (k-1)/k *.........n times = ((k-1)/k) ^ n

 2) What is the expected number of slots that are being nonempty?

 Ans: we can have k non empty slots,if keys go into the all slots of the table.

       similarly we can have k-1,k-2,k-3,.....,1.

              we can have any number from 1 to k-1 being non empty..
selected by

Related questions

0 votes
0 votes
1 answer
1
Himanshu1 asked Dec 16, 2015
780 views
0 votes
0 votes
1 answer
3
nandini gupta asked Jan 22, 2017
684 views
A hash table of length 100 uses chaining.What is the probability that all the values are hashed into the same slot after 5 insertions?