A random file has 13 record positions numbered 0 to 12. The hash function is Key MOD 13 and a collision is resolved by using the next free position. The file is empty. Records with keys 150 and 59 are stored in that order. Where is each one stored?
- 150 MOD 13: 13 × 11 = 143 and 150 − 143 = 7, so key 150 goes to position 7.
- 59 MOD 13: 13 × 4 = 52 and 59 − 52 = 7, so key 59 also hashes to position 7. This is a collision.
- Position 7 is full, so the next position, 8, is tried. It is free.
Answer: Key 150 is in position 7 and key 59 is in position 8.