Computer Science 9618/22 May/June 2025: question paper and mark scheme
Cambridge AS & A Level Computer Science (9618), Paper 2 Fundamental Problem-solving and Programming Skills, May/June 2025. Read both free below, or download them. Done the paper? Get it marked by AI against this mark scheme.
A program is being developed to control the production line in a factory.
(a) A number of different program life cycles are available for the development of a program.
(i) Explain the need for different program development life cycles.
…… [1]
(ii) Coding is a stage in a program development life cycle.
State one consideration that would influence the choice of programming language.
…… [1]
(b) The program has been in use for a number of months and adaptive maintenance is required.
(i) Give three reasons why adaptive maintenance may be required.
1 ……
2 ……
3 ……
[3]
(ii) As well as adaptive maintenance, other types of program maintenance may be needed.
Identify one other type of program maintenance.
…… [1]
(c) Pseudocode has been used to design modules for the program to control the production line.
The table shows four valid pseudocode expressions.
Complete the table by giving the data type of the evaluated expression.
Expression Data type
RIGHT(MachineCode, 4)
Speed * 2.5
NOT Status
IS_NUM(Check)
[4]
(d) A global array Product is used as part of the pseudocode design being developed to control the production line. Product is used to store the number of rejected items each day.
The following pseudocode statement is used to assign a value to an element of the array:
Product[x, y] 23
The lower and upper bound values are shown in the table:
Variable Lower bound Upper bound x 0 99 y 0 9
(i) State the number of dimensions of Product
…… [1]
(ii) State the total number of elements in array Product
…… [1]
(iii) Give the pseudocode declaration for the array Product
…… [2]
Mark scheme
1(a)(i) One mark for 1
Choice of program development cycle depends on the approach/method
required to produce the program
Or
One mark for a factor that would influence the choice of program development
cycle, e.g.
• Rapid development of program/prototypes required
• Need for prototypes (at an early stage)
• Complexity of problem
• Skills / experience of development team / programmer(s)
• Budget / Time / Resources available
• Size of development team
• Developer / programmer can return to earlier stages / any stage
• Avoidance of repeating previous stages in development of program
• How much involvement clients will have
• Allows the (program) requirements to be changed during program
development
• (Program) requirements agreed at start of development of program
Max 1
1(a)(ii) Which programming language would best be suited to control the production 1
line // Which programming language would best suit the problem being solved
1(b)(i) Examples include: 3
• Change to (production line) requirements
• New technology / hardware available (to control production line)
• Changes made to library modules used
• Change in relevant legislation
Max 3
1(b)(ii) Perfective // Corrective 1
1(c) 1 mark for each correct row 4
Expression Data type
RIGHT(MachineCode, 4) STRING
Speed * 2.5 REAL
NOT Status BOOLEAN
IS_NUM(Check) BOOLEAN
1(d)(i) Two / 2 1
1(d)(ii) 1000 1
1(d)(iii) DECLARE Product : ARRAY [0:99, 0:9] OF INTEGER 2
1 mark for correct upper and lower bound
• [0:99, 0:9
1 mark for all other parts of declaration
DECLARE Product : ARRAY [0:99, 0:9] OF INTEGER
A program to calculate the pay of employees working for a company is being designed.
(a) Stepwise refinement has been used in the design of the program.
Describe stepwise refinement.
…… [2]
(b) One of the program modules used to calculate employees’ weekly bonus pay has been completed. The amount of bonus pay they receive is based on the number of hours worked and the value of sales made as shown in the table.
Bonus pay and value of sales are both in dollars.
Hours worked Value of sales Bonus pay between 1 and 40 inclusive 2000 or less 0
between 1 and 40 inclusive above 2000 50 above 40 2000 or less 10 above 40 above 2000 100
(i) The module is tested using white‑box testing.
State two tests, using valid data, that can be used to test different paths through the program.
Test one:
Hours worked ……
Value of sales ……
Bonus pay ……
Test two:
Hours worked ……
Value of sales ……
Bonus pay ……
[2]
(ii) The program to calculate pay uses a number of modules which are each called from different places in the program.
The program is to be tested using stub testing before all the program modules have been completed.
Describe stub testing.
…… [2]
(iii) The program has been completed and compiles successfully.
The program is tested using black‑box testing.
Identify and describe one type of error that black‑box testing could detect.
Type of error ……
Description ……
[2]
Mark scheme
2(a) Mark as follows: 2
1. To increase the level of detail of the algorithm // To break the problem / task
into smaller steps …
2. … until steps can be directly translated into lines of code // from which it
can be programmed
2(b)(i) One mark for each of set test values 2
Hours worked between 1 and 40 inclusive
Sales value <= 2000
Bonus Pay: 0
Hours worked above 40
Sales value <= 2000
Bonus Pay: 10
Hours worked between 1 and 40 inclusive
Sales value > 2000
Bonus Pay: 50
Hours worked above 40
Sales value above 2000
Bonus Pay: 100
max 2
2(b)(ii) One mark per point 2
• Simple modules are written to replace each of the unfinished modules.
• Each simple module will return an expected value / will output a message
to show it has been called.
2(b)(iii) One mark for naming type of error and one mark for corresponding 2
description
Type of error: Logic (error)
Description: Where the program does not behave as expected / Does not
give expected result / An error in the logic of the algorithm
Or
Type of error: Run-time (error)
Description: The program performs an illegal operation
Max 2
An algorithm is designed to generate and output two unique random integers. Each integer value is between –10 and 10 inclusive.
If both integers output are negative, a third random integer between 30 and 35 inclusive will be generated and output.
Write pseudocode for this algorithm.
…… [8]
Mark scheme
3 Example solution 8
DECLARE FirstNumber : INTEGER
DECLARE SecondNumber : INTEGER
DECLARE ThirdNumber : INTEGER
FirstNumber ← INT(RAND(21)) – 10
OUTPUT FirstNumber
REPEAT
SecondNumber ← INT(RAND(21)) – 10
UNTIL FirstNumber <> SecondNumber
OUTPUT SecondNumber
IF FirstNumber < 0 AND SecondNumber < 0 THEN
ThirdNumber ← INT(RAND(6)) + 30
OUTPUT ThirdNumber
ENDIF
Mark points:
1. Declare all variables used
2. Use RAND() function with any integer parameter
3. Use INT() function with any numeric parameter
4. Conditional loop until two different random numbers are generated
5. Use INT() function using random number generated between −10 and 10
inclusive in a loop
6. Output two different random integers / numbers
7. Check if both random integers / numbers are negative
8. then output a (third) random integer / number between 30 and 35 inclusive
An algorithm will:
• input 100 integer values, one value at a time
• store the first value input into the first location of the array Number
• store the next input value in the next unused location of the array Number
• output the contents of Number array in the opposite sequence to that in which the values were input.
Complete the program flowchart to represent the algorithm.
Variable declarations are not required.
START
END
[6]
Mark scheme
4 6
One mark for each functional group as listed:
1. Initialise Index used for Number to either 1 or 0 before first loop
2. Loop 100 times
3. Input value
4. Increment array index and store value in Number array at element
referenced by array index in a loop
5. Output loop starts at last element in Number array
6. Output Number array element referenced by Index in a loop
7. Output all elements of Number array once in reverse order
Max 6
An automated digital camera system is used to take a sequence of pictures of animals in a garden.
During the design of the system, a state‑transition diagram is produced.
The table details the states in the automated digital camera system along with the events which cause the states to change.
The system starts in standby mode. The sequence of pictures is taken when in active mode.
Current state Event Next state standby mode turn on detect mode
detect mode turn off standby mode detect mode movement detected active mode active mode 20 seconds elapsed sequence complete active mode turn off standby mode sequence complete time saved detect mode
(a) Complete the state‑transition diagram for the automated digital camera system.
start
standby mode
[4]
(b) At the end of each sequence of pictures, the time is saved as a string in the format
<HH><MM><SS> where:
• HH represents the hours using two digits
• MM represents the minutes using two digits
• SS represents the seconds using two digits.
For example:
• "081230" is stored to represent the time 8:12:30, in the morning
• "152235" is stored to represent the time 15:22:35, in the afternoon.
Each string is stored on a new line in the text file TimeTaken.txt
An algorithm is required to process the content of the text file TimeTaken.txt once it has been transferred to the computer.
For each hour when pictures are taken, output a suitable message showing the hour and the total number of sequences of pictures taken within that hour.
Example outputs:
Hour : 15 Total : 32
Hour : 18 Total : 1
Write pseudocode for this algorithm.
Assume the text file TimeTaken.txt contains at least one line.
…… [8]
Mark scheme
5(a) 4
Mark as follows:
1 Mark: The three new states drawn and labelled.
1 Mark: Two of the events drawn with labels connecting correct states and
correct line direction
1 Mark: Four of the events drawn with labels connecting correct states and
correct line direction.
1 Mark: All and only six events drawn with labels connecting correct states
and correct line direction.
5(b) Conditional Solution 8
Example Solution
DECLARE Count : INTEGER
DECLARE Line : STRING
DECLARE NextHour, Hour : STRING
OPENFILE "TimeTaken.txt" FOR READ
Count ← 1
READFILE "TimeTaken.txt", Line
Hour ← LEFT(Line, 2)
WHILE NOT EOF("TimeTaken.txt")
READFILE "TimeTaken.txt", Line
NextHour ← LEFT(Line, 2)
IF NextHour = Hour THEN
Count ← Count + 1
ELSE
OUTPUT "Hour : ", Hour, " Total : ", Count
Hour ← NextHour
Count ← 1
ENDIF
ENDWHILE
OUTPUT "Hour : ", Hour, " Total : ", Count
CLOSEFILE "TimeTaken.txt"
Mark as follows:
1. Any Initialisation of count for number of pictures taken each hour
2. Open "TimeTaken.txt" for read and subsequently close
3. Conditional loop until EOF
4. Read a line from "TimeTaken.txt" in a loop
5. Extract Hour from line read in a loop
6. A mechanism to compare current hour extracted from file with last one
read from file in a loop
7. If hours same increment count in a loop
8. If not same output count (with a suitable message) and
update Hour ← NextHour and set Count to 1 in a loop
9. Output final Count and Hour (with a suitable message) once only
Note: max 8
5(b) Alternative solution and mark scheme use of an array to hold count for each
hour
Also, for use of 24 variables and 24 selection conditions
DECLARE HoursArray[0 : 23] OF INTEGER
DECLARE Index, Hour : INTEGER
DECLARE Line : STRING
FOR Index ← 0 TO 23
HoursArray[Index] ← 0
NEXT Index
OPENFILE "TimeTaken.txt" FOR READ
WHILE NOT EOF("TimeTaken.txt")
READFILE "TimeTaken.txt", Line
Hour ← STR_TO_NUM(LEFT(Line, 2))
HoursArray[Hour] ← HoursArray[Hour] + 1
ENDWHILE
FOR Index ← 0 TO 23
IF HoursArray[Index] <> 0 THEN
OUTPUT "Hour : ", Index, " Total : ",
HoursArray[Index]
ENDIF
NEXT Index
CLOSEFILE "TimeTaken.txt"
Mark as follows:
1. Initialisation of 24 array elements to 0 // Initialisation of 24 Integer variables
to 0
2. Open "TimeTaken.txt" for read and subsequently close
3. Conditional loop until EOF
4. Read a line from "TimeTaken.txt" in a loop
5. Extract Hour from line read in a loop
6. Convert Hour to an integer value in a loop
7. Increment appropriate array element / variable in a loop
8. Output of each hour and corresponding count variable (with a suitable
message) for all values where count is not zero
Two arrays Data and Pointer are accessed by the procedure Place()
Data and Pointer are both global arrays of type INTEGER
The contents of these two arrays are shown:
Data Pointer
1 1018 1 7
2 1007 2 3
3 1010 3 1
4 1056 4 6
5 1092 5 -1
6 1062 6 5
7 1034 7 4
8 0 8 9
9 0 9 10
10 0 10 -1
Study the pseudocode:
PROCEDURE Place(Value : INTEGER, Start : INTEGER, Unused : INTEGER)
DECLARE New, Current, Last : INTEGER
CONSTANT NullPointer = -1
New Unused
Last NullPointer
Current Start
WHILE Current <> NullPointer AND Data[Current] < Value
Last Current
Current Pointer[Current]
ENDWHILE
Pointer[New] Pointer[Last]
Pointer[Last] New
Data[New] Value
(a) (i) Complete the trace table below by dry running the procedure Place() when it is called by the statement:
CALL Place(1043, 2, 8)
Value Start Unused New Last Current
[4]
(ii) Complete the diagram showing the contents of the global arrays Data and Pointer after the procedure Place() has run to completion when called as shown in part (a)(i).
Data Pointer
1 1018 1
2 1007 2
3 1010 3
4 1056 4
5 1092 5
6 1062 6
7 1034 7
8 8
9 9
10 10
[3]
(b) The operation carried out by procedure Place() together with the arrays form part of the implementation of an Abstract Data Type (ADT).
Identify the ADT and state the operation carried out by procedure Place()
…… [2]
Mark scheme
6(a)(i) Value Start Unused New Last Current 4
1043 2 8 8 –1 2 Region 1
2 3 Region 2
3 1 Region 3
1 7
7 4 Region 4
Award 1 mark per region
6(a)(ii) Data Pointer 3
1 1018 1 7
2 1007 2 3
3 1010 3 1
4 1056 4 6
5 1092 5 –1
6 1062 6 5
7 1034 7 8
8 1043 8 4
9 0 9 10
10 0 10 –1
Mark as follows:
1 mark for global array Data row 8 containing the value 1043
1 mark for global array Pointer row 7 containing the value 8 and row 8
containing the value 4
1 mark for all other rows in both arrays
6(b) Example answer: 2
The ADT is a linked list and the procedure Place()inserts / add a new node /
value into it / the linked list
Mark as follows:
1. 1 mark for identifying the ADT as a linked list
2. 1 mark for identifying operation as inserting / adding a value / node into a
linked list
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 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
FindCustomer()
• 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
(a) Write efficient pseudocode for module FindCustomer()
…… [8]
(b) A customer can claim a free coffee for every 11 loyalty points.
The programmer has defined a second program module:
Module Description
• output the customer ID for each customer who has 11 or more loyalty points
PointsReport()
• 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]
(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.
(i) Explain why the 2D array Loyalty can no longer be used.
…… [1]
(ii) Explain how a 1D array could be used to store both the loyalty points and the amended customer ID.
…… [2]
Mark scheme
7(a) Example solution Conditional Loop 8
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
7(a) 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 TO 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
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
7(a) 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
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
7(a) 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
7(b) Example solution 7
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
4. … or terminates when column1 of Loyalty array equals 99999 in a loop
5. Check if loyalty points greater than or equal to 11 in a loop
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
7(c)(i) An array can only store data of the same type // An array cannot store data 1
of different types
7(c)(ii) 1 mark for each point 2
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
Checked your answers against these? Let AI mark the whole paper, on your own working.
Examiners follow the generic marking principles at the front of the scheme, then each question's points: method (M), accuracy (A) and independent (B) marks, error carried forward where the scheme allows it, and positive marking, so you're credited for what you got right.
Check your answers against it
Done this paper? Upload your script and CIE Buddy's AI marker marks it question by question against this exact scheme, puts the ticks on your own working and says what each lost mark needed.
Where can I find the 9618/22 May/June 2025 mark scheme?+
On this page, free: the mark scheme for AS & A Level Computer Science 9618/22, May/June 2025 (9618_s25_ms_22), and the question paper (9618_s25_qp_22), to read or download, with each question's marking points written out underneath.
How many marks is 9618/22 out of?+
Computer Science 9618/22 for May/June 2025 is out of 75 marks, with 2 hours to answer it.
Can I get my 9618/22 answers marked?+
Yes. Upload your answers to 9618/22/M/J/25 as a PDF or photos, and CIE Buddy marks every question against this paper's official mark scheme, using Cambridge's marking rules. You get your score, each lost mark explained on your own script, and the topics to revise. It's a guide, not an official Cambridge grade.