Past-paper question · 2021 May-June · Paper 41 · Q2(b)(iii)

Question 2(b)(iii) 2021 · May-June · Paper 41 · 5 marks

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

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
✓
Example code:
✓
FUNCTION getCustomer(customerID) RETURNS customer
✓
DECLARE customerRec : customer
✓
filename = "customerRecords.dat"
✓
OPENFILE filename FOR RANDOM
✓
SEEK filename, getRecordLocation(customerID)
✓
GETRECORD filename, customerRec
✓
CLOSEFILE filename
✓
RETURN customerRec
✓
ENDFUNCTION
✓
9608/41
✓
Cambridge International AS & A Level – Mark Scheme
✓
May/June 2021
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_s21_ms_41.pdf →

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
  • calculated hash value

  • reads and returns the record from the hashed location in the file

customerRecords.dat

You can assume that both the file and the record being accessed exist.

Write pseudocode for the function getCustomer().

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.....................................................................................................................................

[5]

Question 8

Topic relevance

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_41.pdf

Keep practising this topic