Skip to main content

Hash table with chaining, m = 13

Short answer

With h(k)=k mod 13 and chaining, the hash table lists are: 1→27, 2→28, 4→43→30, 5→5, 6→19, 7→20, 9→22, 12→25; other slots empty.

Insert the following data elements into hash table using hash function h(k) = k mod m, take m = 13, assume collisions are handled by chaining. Keys for hashing are: 5, 28, 19, 25, 20, 43, 22, 27, and 30.

h(k) = k mod 13, collisions handled by chaining (new key added at the end of the list).

Keyk mod 13Slot
555
2828 − 26 = 22
1919 − 13 = 66
2525 − 13 = 1212
2020 − 13 = 77
4343 − 39 = 44
2222 − 13 = 99
2727 − 26 = 11
3030 − 26 = 44 (collision with 43)

Hash table

 0 -> NULL
 1 -> 27 -> NULL
 2 -> 28 -> NULL
 3 -> NULL
 4 -> 43 -> 30 -> NULL
 5 -> 5 -> NULL
 6 -> 19 -> NULL
 7 -> 20 -> NULL
 8 -> NULL
 9 -> 22 -> NULL
10 -> NULL
11 -> NULL
12 -> 25 -> NULL

Only one collision occurs (30 with 43 at slot 4).

✓ Answer checked by Claude Opus 5.5 (high effort)

All Data Structure and Algorithm chapter 8 questions →