856 views
5 votes
5 votes
Consider a hash table with 8 slots that uses chaining for collision resolution .The table is initially empty .what is probability that after 4 keys inserted at least a chain of 3 created?

2 Answers

Best answer
5 votes
5 votes

Case I : All going to one slot

$(\frac{1}{8})^3  \ 1^{st} insertion=1 \ ,  rest = \frac{1}{8}$

Case 2 :Second third or fourth  any one is going to different slot :  

 $ \frac{21}{8^3} \ 1^{st} insertion=1 \ $ then $3_{c_2}*(\frac{1}{8})^2 * \frac{7}{8}$

Case 3 : 1st one is going different and other three insertions are going to one slot :

$ \frac{7}{8^3} \ 1^{st} insertion=1 \ $ then $ \frac{7}{8}*(\frac{1}{8})^2$

Adding all of these : $\frac{1}{8^3} + \frac{21}{8^3} + \frac{7}{8^3}= \frac{29}{8^3}$

selected by
3 votes
3 votes
For every key, we have 8 choices, So total permutation = 8^4
P(chain of at least 3 is created) = P(chain of 4)+ P(chain of 3)

permutations for a chain of 4 = 8C1  [as we have 8 slots and we have to choose 1 slot for every element]

permutation for a chain of 3 = 4C1 * 8C1 * 7 [here 3 keys will be at the same slot and 1 will be at in one of the remaining 7 slots.]

P(chain of atleast 3 is created) = ( 8 + 4*8*7)/8^4
P = 29/512

Related questions

0 votes
0 votes
0 answers
1
rsansiya111 asked Mar 12, 2022
375 views
Canadian postal codes have the format LDL DLD, where L is always a letter (between A-Z), D is always a digit (0-9), and is always a single space. For example, the postal ...
0 votes
0 votes
1 answer
3
Ram Swaroop asked Jan 27, 2019
1,314 views
Consider the hashing table with 'm' slots and 'n' keys. If the expected number of probes in unsuccessful search is 3. The expected number of probes in a successful search...