Hash functions
Simple choice:
- Table size M
- Hash function h(K) = K mod M;
Works fine if keys are random integers.
Example: 20 random keys in [1..100]
[56, 82, 87, 39, 98, 86, 69, 22, 99, 61,
64, 50, 77, 75, 8, 62, 17, 10, 71, 58]
…hashed in a table of size 20
[16, 2, 7, 19, 18, 6, 9, 2, 19, 1, 4, 10, 17, 15, 8, 2, 17, 10, 11, 18]