1,176 views
5 votes
5 votes

Consider a hash table with $n$ buckets, where external(overflow) chaining is used to resolve collision. The hash function is such that the probability that a key value is hashed to a particular bucket is $\dfrac 1 n$. The hash table is initially empty and $k$  distinct values are inserted in the table.

Q) What is the probability that bucket number $1$ is empty after the $k^{th}$ insertion?

  1. $n$
  2. $(n - 1)^k$
  3. $((n-1)/n)^k$
  4. $((n-1)/k)^n$

Q).  What is the probability that no collision has occurred in any of the $k$ insertions?

  1. $n(n - 1)(n - 2)(n - k + 1)/n^k$
  2. $n(n - 1)(n - 2)(n - k - 1)/n^k$
  3. both (a) and (b)
  4. none

2 Answers

Best answer
7 votes
7 votes

1.  If bucket no 1 is empty after $k$ insertions that means keys must have mapped to remaining $n-1$ locations. $k$ insertions means $k$ keys mapped. Probability of bucket 1 being empty $= \left({\frac{n-1}{n}}\right)^k$

Ans C

2. No collision in $k$ insertions
Insertion 1: $\frac{n}{n}$ (key can go to any one of $n$ positions)
Insertion 2: $\frac{n-1}{n}$ (key can go to any one of $n-1$ remaining positions).
insertion 3: $\frac{n-2}{n}$ and continuing in same way
Insertion $k$: $\frac{n-(k-1)}{n}$
so we get Probability of no collision = $\frac{n.(n-1).(n-2)\dots(n-k+1)}{n^k}$
Ans A

selected by
3 votes
3 votes

Q.1] probability that the hash fun mapping a key to a bucket number 1= 1/n 
 probability that the hash fun not mapping a key to a bucket number 1= 1-(1/n)
probability that the bucket no. 1 is empty after 2 iteration= First Time  Missed And Second Time Missed =
(n-1/n) (n-1/n)
none of these k keys mapped to bucket no. 1 after k Iteration=(n-1/n) (n-1/n) (n-1/n)...k times =
(n-1/n)^k Option C

For K=1, it's 1. For K=2, the second item must miss the bucket of the first item. 
So it has n−1 places it can go safely. The probability of success is therefore n−1/n
So the probability for K=3is 1*n−1/n*n−2/n.
similarly for P(k) = 1*n−1/n*n−2/n*n-3/n............n+1-k/n

Related questions

0 votes
0 votes
1 answer
1
0 votes
0 votes
1 answer
2
Himanshu1 asked Dec 16, 2015
779 views
0 votes
0 votes
1 answer
4
nandini gupta asked Jan 22, 2017
683 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?