retagged by
1,066 views
0 votes
0 votes
The hash function hash=key mod size and linear probing are used to insert the keys 37,38,72,48,98,11,56 into hash table with indexes 0.....6.the order of the keys in the array are given by

a)98,11,37,38,72,56,48

b)98,56,37,38,72,11,48

c)11,48,37,38,72,98,56

d)72,11,37,38,56,98,48
retagged by

1 Answer

Best answer
3 votes
3 votes
Given array : 37,38,72,48,96,11,56 

The size given = 7 [since indices of hash table ranges from 0 - 6]

So hash function = key mod 7.

So let us perform hashing along with linear probing if collision occurs.

a) 37 mod 7 = 2

b) 38 mod 7 = 3

c) 72 mod 7 = 2 (collision) 

    So (72 + 1) mod 7 = 3(collision)

    So (72 + 2) mod 7 = 4

d)  48 mod 7 = 6

e)  98 mod 7 = 0

f)   11 mod 7 = 4(collision)

 So (11 + 1) mod 7 = 5

g)  56 mod 7 = 0(collision)

  So (56 + 1) mod 7 = 1



So the order of the keys in the hash table will be :

 98   56  37   38   72   11   48



Hence , B) should be the correct option
selected by

Related questions

0 votes
0 votes
1 answer
1
tishhaagrawal asked Dec 16, 2023
311 views
Below is my approach to solving this question, can anyone please explain if I am doing it the right way?Let X = #free slotssince, m =7 and n = 3So, $4 \leqslant x\leqsla...
0 votes
0 votes
1 answer
4
radha gogia asked Mar 7, 2016
712 views
How many key comparisons are there , what is the lower bound and upper bound ? For calculating the lower bound , should we consider the case when the keys are all in non-...