Uploaded by Kevin Truong

CS 430 Module 8 Lab

advertisement
Given a hash table of size 7, integer hash keys k, and a hash function
h1(k) = k%7
a) In which slots are 17, 27, 29 and 42 entered?
17: h1(17) = 17%7 = 3
27: h1(27) = 27%7 = 6
29: h1(29) = 29%7 = 1
42: h1(42) = 42%7 = 0
b) Assume 17, 27, 29 and 42 have been entered using h1 (as in a).
Using chaining draw the hash table when the following are added.
49: h1(49) = 49%7 = 0
Slot 0: 42 -> 49
Slot 1: 29
Slot 2: Empty
Slot 3: 17
Slot 4: Empty
Slot 5: Empty
Slot 6: 27
Slot 7: Empty
70: h1(70) = 70%7 = 0
Slot 0: 42 -> 49 -> 70
Slot 1: 29
Slot 2: Empty
Slot 3: 17
Slot 4: Empty
Slot 5: Empty
Slot 6: 27
Slot 7: Empty
48: h1(48) = 48%7 = 6
Slot 0: 42 -> 49 -> 70
Slot 1: 29
Slot 2: Empty
Slot 3: 17
Slot 4: Empty
Slot 5: Empty
Slot 6: 27 -> 48
Slot 7: Empty
Download