Past-paper question · 2017 May-June · Paper 31 · Q4(b)(iii)

Question 4(b)(iii) 2017 · May-June · Paper 31 · 4 marks

Original past-paper question for 4(B)(III)
Original past-paper question for 4(B)(III)
Reveal official mark-scheme answer Official mark-scheme answer for 4(B)(III)

Official answer for Question 4

Part (b)

(iii)

✓
PROCEDURE InsertRecord(CustomerID : INTEGER)

Question 4

✓
RecordKey ← CustomerID MOD 100000
✓
Success ← FALSE
✓
// Find position for new record and insert it
✓
REPEAT
✓
IF record at position RecordKey is empty
✓
THEN
✓
Insert new record at position RecordKey
✓
Success ← TRUE
✓
ELSE
✓
IF RecordKey = 99999
✓
THEN
✓
RecordKey ← 0
✓
ELSE
✓
RecordKey ← RecordKey + 1
✓
ENDIF
✓
ENDIF
✓
UNTIL Success = TRUE
✓
ENDPROCEDURE

Mark scheme 9608_s17_ms_31.pdf →

Show text version of question

Question 4

Part (b)

(iii)

Question 4

A bank has 95 000 customers. Each customer has a unique ID.

When a customer uses an Automated Teller Machine (ATM) to obtain cash, their current balance is checked. The balance is stored in a file which has the following fields:

  • the customer ID (6-digit number in the range 100000 to 999999)
  • an encrypted PIN
  • the current balance

The file can store a maximum of 100 000 records. An algorithm for inserting a new record in this file uses the following hash function:

RecordKey CustomerID MOD 100000

where RecordKey is the record position in the file.

(iii)

A procedure is written to insert a new record into the file.

Complete the algorithm for this procedure.

PROCEDURE InsertRecord(CustomerID : INTEGER) RecordKey CustomerID MOD 100000 Success FALSE // Find position for new record and insert it REPEAT IF record at position RecordKey is ……………………… THEN Insert new record at position RecordKey Success TRUE ELSE IF RecordKey = ……………………… THEN RecordKey ……………………… ELSE RecordKey ……………………… + 1 ENDIF ENDIF UNTIL Success = TRUE ENDPROCEDURE

[4]
Topic relevance

Why this question appears here

82% assigned-topic match · Programming › Constructs

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9608_s17_qp_31.pdf

Keep practising this topic