Helped me a lot.

Thank you so much for giving this one shot learning tutorial.

]]>—

The first half of collision resolution is to visit table indices via this

recurrence:

j = ((5*j) + 1) mod 2**i

For any initial j in range(2**i), repeating that 2**i times generates each

int in range(2**i) exactly once (see any text on random-number generation for

proof).

—

and

—

Note that because perturb is unsigned, if the recurrence

is executed often enough perturb eventually becomes and remains 0. At that

point (very rarely reached) the recurrence is on (just) 5*j+1 again, and

that’s certain to find an empty slot eventually (since it generates every int

in range(2**i), and we make sure there’s always at least one empty slot).

—

]]>j = (5*j) + 1 + perturb;

perturb >>= PERTURB_SHIFT;

use j % 2**i as the next table index