Skip to main content
A-LevelComputer ScienceData types and structures9618/22 · May/June 2025 · Q718 Marks

A program is being developed to implement a customer loyalty scheme for a coffee shop. Each customer has a unique customer ID starting at 10001 with this value increasing by one each time a new customer joins the loyalty scheme. For example, the third customer who joins the loyalty scheme is given the customer ID 10003 The loyalty scheme is limited to 1000 customers. A customer is awarded a loyalty point every time they buy a coffee. The programmer has decided to use a global 2D array Loyalty of type INTEGER. The array Loyalty is made up of 1000 rows and 2 columns. Each row relates to one customer; column 1 contains the unique customer ID and column 2 contains the number of customer loyalty points. Rows in the array Loyalty that are not currently being used have the value of Column 1 set to 99999 The array is sorted in ascending order by customer ID. The programmer has defined a program module: Module FindCustomer() Description • called with parameter of type INTEGER representing a customer ID • searches the Loyalty array for this customer ID • the search will stop as soon as the customer ID is found • the search should efficiently deal with the situation when the customer ID is not stored in the Loyalty array • if the customer ID is found, return an integer value representing the loyalty points, otherwise return -1

  1. (a)Write efficient pseudocode for module FindCustomer()[8]
  2. (b)A customer can claim a free coffee for every 11 loyalty points. The programmer has defined a second program module: Module PointsReport() Description • output the customer ID for each customer who has 11 or more loyalty points • output the average loyalty points for all customers in the Loyalty array along with an appropriate message Write efficient pseudocode for module PointsReport() Assume the array contains the data for at least one customer.[7]
  3. (c)The programmer decides to amend the customer ID; it will be stored as a STRING instead of an INTEGER. This means that the 2D array Loyalty can no longer be used.
  4. (c)(i)Explain why the 2D array Loyalty can no longer be used.[1]
  5. (c)(ii)Explain how a 1D array could be used to store both the loyalty points and the amended customer ID.[2]

Mark scheme

Marking points from the official mark scheme (May/June 2025). The mark or mark type is shown in brackets.

  1. [8] Example solution Conditional Loop FUNCTION FindCustomer(CustomerID : INTEGER) RETURNS INTEGER DECLARE Index : INTEGER DECLARE Found : BOOLEAN CONSTANT Unused = 99999 CONSTANT Upper = 1000 Found← FALSE Index 1 IF CustomerID < 10001 OR CustomerID > 11000 THEN RETURN -1 // Out of range value for customer ID ENDIF WHILE Found = FALSE AND Loyalty[Index, 1] <> 99999 IF Loyalty[Index,1] = CustomerID THEN Found← TRUE ELSE Index Index + 1 ENDIF IF Index > Upper THEN RETURN -1 ENDIF ENDWHILE IF Found THEN RETURN Loyalty[Index, 2] ELSE RETURN -1 ENDIF ENDFUNCTION Mark as follows: 1. Create function header and ending with correct parameter and return type 2. Check CustomerID is in range and if not return -1 3. (Conditional) loop iterating through each element in array 4. Check for current element in array contains required customer ID in a loop 5. If found set value to terminate loop 6. Terminating loop when customer ID found 7. Terminating loop when current customer ID is 99999 8. Return either loyalty points for the customer found or -1 if not found
  2. [8] Alternative solution using FOR Loop Example solution FUNCTION FindCustomer(CustomerID : INTEGER) RETURNS INTEGER DECLARE Index : INTEGER IF CustomerID < 10001 OR CustomerID > 11000 THEN RETURN -1 // Out of range value for customer ID ENDIF FOR Index ← 1 ΤΟ 1000 IF Loyalty[Index, 1] = CustomerID THEN RETURN Loyalty[Index, 2] ENDIF IF Loyalty[Index, 1] = 99999 THEN RETURN -1 ENDIF NEXT Index ENDFUNCTION Mark as follows: 1. Create function header and ending with correct parameter and return type 2. Check CustomerID is within range and if not return -1 3. FOR Loop 4. Loop for elements 1 to 1000 / 0 to 999 5. Check if current element in array contains required Customer ID in a loop 6. If found correctly return loyalty points // store correct loyalty points and return after loop 7. Check if current element in array is 99999 and return -1 / break loop in a loop 8. return-1 if Customer ID not found
  3. [8] Direct access solution Alternative solution subtracting 10000 from CustomerID FUNCTION FindCustomer(CustomerID : INTEGER) RETURNS INTEGER DECLARE Index : INTEGER IF CustomerID < 10001 OR CustomerID > 11000 THEN RETURN -1 // Out of range value for customer ID ENDIF Index = CustomerID - 10000 IF Loyalty[Index, 1] = CustomerID THEN RETURN Loyalty[Index, 2] ENDIF RETURN -1 ENDFUNCTION Mark as follows: 1. Create function header and ending with correct parameter and return type 2. Declare Index as Integer 3. Check CustomerID is less than 10001 and return -1 if it is 4. Check CustomerID is greater than 11000 and return -1 if it is 5. Calculate Index by subtracting a 10000 form CustomerID 6. Check if array contains the CusomerID 7. Return Loyalty Points if CustomerID found 8. Return -1 if not found
  4. [8] Binary Search Mark Scheme Example Solution FUNCTION FindCustomer(CustomerID : INTEGER) RETURNS INTEGER DECLARE Start : INTEGER DECLARE End : INTEGER DECLARE Mid : INTEGER IF CustomerID < 10001 OR CustomerID > 11000 THEN RETURN -1 // Out of range value for customer ID ENDIF Start 1 End 1000 WHILE Start <= End Mid ← (Start + End) DIV 2 IF Loyalty[Mid, 1] = CustomerID THEN RETURN Loyalty[Mid, 2] ELSE IF Loyalty[Mid, 1] > CustomerID THEN End Mid 1 ELSE Start Mid + 1 ENDIF ENDWHILE RETURN -1 ENDFUNCTION Mark points: 1. Create function header and ending with correct parameter and return type 2. Check CustomerID is within range and if not return -1 3. Conditional loop that halves array search space with each iteration 4. Check if CustomerID is stored in current array element in loop 5. Mechanism to end loop if CustomerID is found in array in a loop 6. Mechanism to end loop if CustomerID is not in array in a loop 7. If CustomerID found in array then return correct loyalty points 8. If CustomerID not in array then return -1
  5. [7] Example solution PROCEDURE PointsReport() DECLARE Count : INTEGER DECLARE Index : INTEGER DECLARE Sum : INTEGER DECLARE Average : REAL Index ← 1 Count 0 Sum 0 WHILE Loyalty[Index, 1] <> 99999 AND Index <= 1000 IF Loyalty[Index, 2] >= 11 THEN OUTPUT Loyalty[Index, 1] ENDIF Count Count + 1 Sum Sum + Loyalty[Index, 2] Index ← Index + 1 ENDWHILE Average ← Sum / Count OUTPUT "The average points of all the customers is ", Average ENDPROCEDURE Mark as follows: 1. Create procedure header and ending 2. Declare and initialise Index, Sum and Count 3. Loop through all elements in Loyalty array Check if loyalty points greater than or equal to 11 in a loop 4. or terminates when column1 of Loyalty array equals 99999 in a loop 5. 6. If true output customer ID 7 Sum points and Increment Count in a loop 8 Calculate and output average with an appropriate message Max 7
  6. [1] An array can only store data of the same type // An array cannot store data of different types
  7. [2] 1 mark for each point 1. a new (composite) data type / record is defined (that consists of both INTEGER and STRING) 2. an array based on this new type is declared Alternative 1 mark for each point 1. Converting loyalty points to string and concatenating / joining / append with Customer ID 2. Storing concatenated string in an array of string

Write your answer and get it marked

On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.

Sign up free →

About this question

Topic
Data types and structures, A-Level Computer Science (syllabus 9618). Structured question, 18 marks.
Source
A-Level Computer Science, May/June 2025 Paper 2 Variant 2, question 7.

Questions and mark schemes are from past examination papers and remain the copyright of the exam board. How Oracle Prep builds its content

Related Computer Science questions

© 2026 Oracle Prep