Question 2(b)(iii) 2021 · May-June · Paper 43 · 5 marks
Reveal official mark-scheme answer
Official answer for Question 2
Part (b)
(iii)
Question 1
mark per bullet point to max 5
Question 5
- Function declaration taking Customer ID as parameter returning type customer
- Opening "customerRecords.data" for random
- Calling getRecordLocation() with parameter …
- … storing return value
- Finding location in file using hash value …
- … accessing record from location
- … return value
- Closing file in appropriate place under all conditions
Show text version of question
Question 2
Part (b)
(iii)
Question 2
Peter uses a record structure, customer, to store data about customers. The data includes:
- a unique customer ID between 10 000 and 99 999
- the customer's first name
- the customer's last name
- the customer's telephone number (for example, +44 1234567891).
The customer records are stored in a random file. The location of each record is calculated as a hash value using:
(customer.customerID modulus 1000) + 2
(iii)
The function, getCustomer():
- takes the customer ID as a parameter
- passes the customer ID to the function getRecordLocation(), which returns the
- reads and returns the record from the hashed location in the file
calculated hash value
customerRecords.dat
You can assume that both the file and the record being accessed exist.
Write pseudocode for the function getCustomer().
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.....................................................................................................................................
Question 8
Why this question appears here
71% assigned-topic match · Programming › Structured programming
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_s21_qp_43.pdf
