• edited by
7,725 views
1 1 vote

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)?

1 Answer

4 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.
Position:
Show:

Related questions

60 60 votes
4 answers 4 answers
25.2k
25.2k views
Arjun asked Feb 12, 2020
25,162 views
Consider a double hashing scheme in which the primary hash function is $h_1(k)= k \text{ mod } 23$, and the secondary hash function is $h_2(k)=1+(k \text{ mod } 19)$. Ass...
5 5 votes
3 3 answers
262
262 views
GO Classes asked Jul 18
262 views
A hash table of length $11$ is initially empty. The hash function is:$H(key) = (key \times 3) \bmod 11$Collisions are resolved using quadratic probing:$H_k = (H_0 + k^2) ...
3 3 votes
1 1 answer
1.8k
1.8k views
firki lama asked Jan 17, 2017
1,839 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 5 votes
3 3 answers
7.9k
7.9k views
mcjoshi asked Aug 30, 2016
7,919 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...