Suppose there are five customers from an online retailer with the following IDs
ID: 3635647 • Letter: S
Question
Suppose there are five customers from an online retailer with the following IDsbased on the last three digits from their rewards card: 909, 185, 657, 116, and 150.
Suppose that a hash table HT, is of size 7, indexed with 0, 1, 2, …, 6. Show how these
IDs (in the order given) are inserted in the hash table HT using the hashing function
h(k)= k % 7. Use linear probing to resolve any collisions.
Explanation / Answer
909%7 = 6 => Insert in Bucket 6 185%7 = 3 => Insert in Bucket 3 657%7 = 6 => Bucket 6 is full , so Insert in Bucket (6+1)%7 = 0 116%7 = 4 => Insert in Bucket 4 150%7 = 3 => Bucket 3 is full, 4 is full so insert in Bucket 5