9618/31/M/J/23 question 3: worked solution (May/June 2023, paper 31)
Show as plain textHide plain text
Cambridge A2 Level Computer Science 9618 · 13.2 File organisation and access Worked solution from the Data Representation Paper 3 Advanced Theory booklet, Part 2 of 3. Q23 9618/31/M/J/23 original Q3 Structured · 6 marks 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 key Hash value 1030 1 1050 0 1025 2 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 IDEA A 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 VIDEO ▶ Whole paper Video solution of the whole paper · by qiphyedu. Tap the picture to open it on YouTube.