Worked solution from the Data Representation Paper 3 Advanced Theory booklet, Part 2 of 3.
Divide each key by 3 and write the remainder. 1050 ÷ 3 = 350 exactly, so the remainder is 0. 1025 ÷ 3 = 341 remainder 2 (3 × 341 = 1023).
| Record key | Hash value |
|---|---|
| 1030 | 1 |
| 1050 | 0 |
| 1025 | 2 |
Write 0 for 1050 [1]
Write 2 for 1025 [1]
This is called a collision. Two different keys have given the same hash value.
Write: the storage location worked out by the hash is already used by another record [1]
If the record is being stored: search the file linearly (one space after another) from that location [1]
... to find the next free storage space and store the record there [1]
If the record is being retrieved: search linearly from that location (or in the overflow area) until the matching record key is found; if it is not found, the record is not in the file [1]
Both closed hash (next free space in the file) and open hash (overflow area) are accepted.
▶ Whole paper
Video solution of the whole paper · by qiphyedu. Tap the picture to open it on YouTube.
Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.