You are on page 1of 1

Quiz 3

Solution

For h(k) = ki % m = ki % 10,


h(33) = 33 % 10 = 3
h(54) = 54 % 10 = 4
h(69) = 69 % 10 = 9
h(74) = 74 % 10 = 4
h(18) = 18 % 10 = 8
h(19) = 19 % 10 = 9
h(14) = 14 % 10 = 4

As, we can see that there are three collisions. First at key 74, second at key 19 and third at key 14.

We will use linear probing for collision resolution,


h(74) = (74 % 10) + 1 = 5
h(19) = (19 % 10) + 1 = 0
h(14) = (14 % 10) + 1 = 5
h(14) = (14 % 10) + 2 = 6

So the hash table becomes,

Index Keys Probes


0 19 2
1
2
3 33 1
4 54 1
5 74 2
6 14 3
7
8 18 1
9 69 1

You might also like