Open In App

UGC-NET | UGC NET CS 2018 July – II | Question 23

Like Article
Like
Save
Share
Report

A hash function h defined 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 ?
(A) 3
(B) 4
(C) 5
(D) 6


Answer: (C)

Explanation: keys 44, 45, 79, 55, 91, 18, 63
h(key)=key mod 7
h(44) = 44mod7 = 2
h(45) = 45mod7 = 3
h(79) = 79mod7 = 2
but 2 is already filled 44, linear probing is applied but 3 ias also filled.
So, 79 will occupy 4.
h(55) = 55mod7 = 6
h(91) = 91mod7 = 0
h(18) = 18mod7 = 4 but 4 is occupied by 79 so, it will occupy 5.
h(63) = 63mod7 = 0. 0 is also occupied so, it will occupy 1.
So, option (C) is correct.


Quiz of this Question


Last Updated : 06 Sep, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads