Question Id : 18859 |
Context : UGC NET Computer Science Nov 2021 (Paper II)
A hash function $h$ defined as $h(key)=key\ mod\ 7$, with linear probing, is used to insert the keys $44,45,79,55,91,18,63$ into a table indexed from $0$ to $6$. What will be the location of key $18$?
🎥 Video solution / Text Solution of this question is given below:
Hash function is:
$h(key)=key\ mod\ 7$
Insert keys one by one.
$44\ mod\ 7=2$, so $44$ goes to index $2$.
$45\ mod\ 7=3$, so $45$ goes to index $3$.
$79\ mod\ 7=2$, but index $2$ is filled. Using linear probing, index $3$ is also filled, so $79$ goes to index $4$.