752 views
0 votes
0 votes
Consider a hash table with m slots that uses open addressing with linear probing. The table is initially empty. A key k1 is inserted into the table, followed by keyk2, and then keyk3.What is the probability that the total number of probes while inserting these keys is at least 4?

2 Answers

Best answer
4 votes
4 votes

Probe is how many empty or occupied position are to be "Looked-up" before actually inserting an element.

There are $2$ cases for which total number of probes while inserting these keys is at least $4$ :

  • In terms a collision

$\rightarrow$ $M$ ways to decide for $K1$ ($1$ Probe Done)

$\rightarrow$ Now, only $1$ way for $K2$ to collide with $K1$ (In this case $2$ Probes)

$\rightarrow$ Now, $K3$ can go anywhere ( $4$ Probes Done)

Hence, Probability for this case = $\frac{m}{m} * \frac{1}{m} *\frac{m}{m}$ = $\frac{1}{m}$

  • In terms of No collision occurs

$\rightarrow$  $M$ ways to decide for $K1$ ( $1$ Probe Done)

$\rightarrow$  Now, $K2$ can go anywhere other than $K1$ and having $m -1$ ways to decide (In this case $1$ Probe)

$\rightarrow$  Now, $K3$ can go to either $K1$ or $K2$ ( $4$ Probes Done)

Hence, Probability for this case = $\frac{m}{m}*\frac{m-1}{m}*\frac{2}{m}$ = $\frac{2(m-1)}{m^{2}}$


Hence, Total Probability comes out to be = $\frac{2(m-1)}{m^{2}} + \frac{1}{m}$

selected by
1 votes
1 votes
To insert 3 elements at least 3 probes will be required if no collision happened

$P(X \geq 4) = 1 - P(X = 3)$

$P(X = 3) = \frac{m}{m} \times \frac{m-1}{m} \times \frac{m-2}{m} = \frac{m^2 -3m +2}{m^2}$

$\therefore P(X \geq 4) = 1 - P(X = 3) = 1 - \frac{m^2 -3m +2}{m^2}$

$= \frac{3m-2}{m^2}$
edited by

Related questions

0 votes
0 votes
0 answers
1
shivangi5 asked Oct 31, 2017
347 views
Consider a hashing function that resolves collision by quadratic probing .Assume the address space is indexed from 1 to 6. Which of the following locations will never be ...
0 votes
0 votes
1 answer
2
0 votes
0 votes
1 answer
3
himgta asked Jun 1, 2018
695 views
When we should use hashing and when we should use indexing? what is the difference b/w these two tems ? Explain with taking a practical scenario
1 votes
1 votes
0 answers
4
Aaditya Pundir asked Jan 23, 2018
282 views
Q5) A hash table has space for 100 records. Then the probability of collision before the table is 10% full is?