Insert 18, 41, 22, 44, 59, 32, 31, 73 into a table of size 13 with h(k) = k mod 13, double hashing and d(k) = 7 − k mod 7. Where does each key end up?
31 at 0, 41 at 2, 18 at 5, 32 at 6, 59 at 7, 73 at 8, 22 at 9, 44 at 10. Only 44 and 31 collide.
* Each colliding key jumps by its own step, so the entries spread out instead of forming one block. *
| k | h(k) | d(k) | Cells tried | Placed at |
|---|---|---|---|---|
| 18 | 5 | 3 | 5 | 5 |
| 41 | 2 | 1 | 2 | 2 |
| 22 | 9 | 6 | 9 | 9 |
| 44 | 5 | 5 | 5, 10 | 10 |
| 59 | 7 | 4 | 7 | 7 |
| 32 | 6 | 3 | 6 | 6 |
| 31 | 5 | 4 | 5, 9, 0 | 0 |
| 73 | 8 | 4 | 8 | 8 |
Gotcha: d(k) = 7 − k mod 7 means 7 − (k mod 7), since mod binds like a division. For 44: 44 mod 7 = 2, so d = 5, not (7 − 44) mod 7.
d(k) is only computed when the first cell is taken. 44 collides with 18 at cell 5 and jumps 5 to cell 10. 31 also starts at 5, but with its own step of 4 it tries 9 (taken by 22), then 13 mod 13 = 0, which is free.
Compare linear probing on the same keys: there 32, 31 and 73 also collided, and 31 needed six probes. Here only two keys collide (three collisions in total: 44 once, 31 twice), and no key needs more than three probes.