edited by
6,323 views
1 votes
1 votes

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 probed if a collision occurs at position $5$ ?

A). $4$

B). $5$

C). $8$

D). $6$

Ans:

$B$

Ans Explanation:

f(key) = key % $6+1$ $\rightarrow$ it locates from $1$ to $6$ collision

     Quadratic probing $\rightarrow$ $(5+1^2) $%$ 6+1 =1$

                               $\rightarrow$ $(5+2^2) $%$ 6+1 =4$

                               $\rightarrow$ $(5+3^2) $%$ 6+1 =3$

                               $\rightarrow$ $(5+4^2) $%$ 6+1 =4$

                               $\rightarrow$ $(5+5^2) $%$ 6+1 =1$

                               $\rightarrow$ $(5+6^2) $%$ 6+1 = 6$

                               $\rightarrow$ $(5+7^2) $%$ 6+1 = 1$

                               $\rightarrow$ $(5+8^2) $%$ 6+1 = 4$

                              $\rightarrow$ $(5+9^2) $%$ 6+1 = 3$

so the $5^{th}$ location is never probed 

Here why we are adding $1$ to find f(key)?

edited by

1 Answer

4 votes
4 votes
Because address space is indexed from 1 to 6. If you get 0 after some modulus operation and you don't have zero as any location. Therefore, 1 is added.

Related questions

3 votes
3 votes
1 answer
1
firki lama asked Jan 17, 2017
1,160 views
Given the input sequence {11,33,43,79,19} and hash table of size 10 with the hash function h(k)=k mod 10. If hash tables uses quadratic probing,the number of collisions o...
5 votes
5 votes
3 answers
2
mcjoshi asked Aug 30, 2016
5,594 views
Keys $9,19,29,39,49,59,69$ are inserted into a hash Table of size $10$ $(0-9)$ using the hash function $H = k mod 10$ and Quadratic Probing is used for collision resoluti...
5 votes
5 votes
3 answers
4
atul_21 asked Nov 14, 2017
4,690 views
1.Linear Probing suffers from both primary and secondary clustering. true or false?2. Quadratic Probing suffers from both primary and secondary clustering. true or fal...