Past-paper question · 2021 May-June · Paper 42 · Q2(b)(i)

Question 2(b)(i) 2021 · May-June · Paper 42 · 2 marks

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

Official answer for Question 2

Part (b)

(i)

Question 1

mark per bullet point

Question 2

  • Function header and close taking a booking ID as parameter AND return the calculated value
  • Calculating hash value correctly using parameter
✓
Example code
✓
VB.NET
✓
Function Hash(BookingID)
✓
Hash = BookingID Mod 100000 + 3
✓
End Function
✓
Python
✓
def Hash(BookingID):
✓
HashV = BookingID % 100000 + 3
✓
return HashV
✓
Python alternative: MOD(BookingID, 1000000) + 3
✓
Pascal
✓
Function Hash(BookingID:Integer):Integer
✓
begin
✓
Hash := BookingID MOD 100000 + 3
✓
end;
✓
9608/42
✓
Cambridge International AS & A Level – Mark Scheme
✓
May/June 2021
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_s21_ms_42.pdf →

Show text version of question

Question 2

Part (b)

(i)

Question 2

A company stores bookings in a random file.

For each booking, the booking ID, customer ID, item ID and quantity are stored. These four values are all integers. Each booking ID is a value between 100 000 and 999 999 inclusive.

The hash value is calculated by dividing the booking ID by 100 000 and adding 3 to the remainder.

(i)

The function Hash() takes the booking ID as a parameter, calculates and returns the

hash value.

Write program code for the function Hash().

Programming language .................................................................

Program code

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

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

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

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

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

[2]
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_42.pdf

Keep practising this topic