Cambridge A2 Level Computer Science 9618 · 13.2 File organisation and access

Q23 · 9618/31/M/J/23 Q3

Worked solution from the Data Representation Paper 3 Advanced Theory booklet, Part 2 of 3.

Q239618/31/M/J/23original Q3Structured · 6 marks
Question 3 from 9618/31/M/J/23

Worked solution

(a)

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 keyHash value
10301
10500
10252

Write 0 for 1050 [1]

Write 2 for 1025 [1]

(b)

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.

KEY IDEAA hash value is the key's remainder after division, and a collision means the location is already taken, so search on linearly for a free space or the matching key.
TOTAL 6 marks

Official mark scheme

Mark scheme for 9618/31/M/J/23 question 3
VIDEO
▶ 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.