Cambridge A Level Computer Science 9618 — 2024 Oct/Nov Paper 2 · Variant 3
9618/23/O/N/24 · 8 questions · 75 marks · ≈84 min
The question paper and its mark scheme, free to read here and free to download. This is Cambridge’s own paper, exactly as it was sat.
Question paper20 pages




















Mark scheme14 pages
Answers below. Sit the paper first if you are practising.














Questions as text
Q1 · The following table contains pseudocode examples
1 (a) The following table contains pseudocode examples. Each example may contain statements that relate to one or more of the following: • selection • iteration (repetition) • subroutine (procedure or function). Complete the table by placing one or more ticks ('✓') in each row. Pseudocode example Selection Iteration Subroutine FOR Index ← 1 TO 3 IF Safe[Index] = TRUE THEN Flap[Index] ← 0 ENDIF NEXT Index CASE OF Compound(3) REPEAT UNTIL AllDone() = TRUE WHILE Result[3] <> FALSE [4] (b) Complete the table by giving the appropriate data type in each case. Variable Example data value Data type Available TRUE Received "18/04/2021" Index 100 [3] (c) Evaluate each expression in the table by using the data values shown in part (b). Write ‘ERROR’ if the expression contains an error. Expression Evaluates to Available AND NOT(Index > 100) Index MOD 30 NUM_TO_STR(Index + "33") [3]
Mark scheme: Question Answer Marks 1(a) 4 Pseudocode example Selection Iteration Subroutine FOR Index 1 TO 3 IF Safe[Index] = TRUE THEN Flap[Index] 0 ENDIF NEXT Index CASE OF Compound(3) REPEAT UNTIL AllDone() = TRUE WHILE Result[3] <> FALSE One mark per row 1(b) 3 Variable Example data value Data type Available TRUE BOOLEAN Received "18/04/2021" STRING Index 100 INTEGER One mark per row 1(c) 3 Expression Evaluates to Available AND NOT(Index > 100) TRUE Index MOD 30 10 NUM_TO_STR(Index + "33") ERROR One mark per row
Q2 · An algorithm will: 1
2 An algorithm will: 1. prompt and input a sequence of 100 integer values, one at a time 2. sum the positive integers 3. output the result of the sum. (a) Write pseudocode for the algorithm. Assume the value zero is neither positive nor negative. You must declare all variables used in the algorithm. ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ............................................................................................................................................. [5] (b) The algorithm requires the use of basic constructs. One of these is sequence. Identify one other basic construct required by the algorithm and describe how it is used. Construct .................................................................................................................................. Use ........................................................................................................................................... ................................................................................................................................................... [2]
Mark scheme: 2(a) DECLARE Count, Total, NextNumber : INTEGER 5 Total 0 FOR Count 1 TO 100 OUTPUT "Input an integer value" INPUT NextNumber IF NextNumber > 0 THEN Total Total + NextNumber ENDIF NEXT Count OUTPUT Total Mark as follows: MP1 Declarations of all variables used MP2 Loop for 100 iterations MP3 Prompt and input a value in a loop and MP4 Test for value > 0 // >=1 in a loop MP5 Sum the Total in a loop MP6 Output of Total after the loop Max 5 marks 2(b) MP1 Construct: Iteration / Repetition 2 MP2 Use: To loop through all 100 inputs // To loop 100 times ALTERNATIVE: MP1 Construct: Selection MP2 Use: To test whether the value input is positive
Q3 · The implementation of a linked list uses an integer variable and a 1D array List of type…
3 The implementation of a linked list uses an integer variable and a 1D array List of type Node. Record type Node is declared in pseudocode as follows: TYPE Node DECLARE Data : STRING DECLARE Pointer : INTEGER ENDTYPE The array List is declared in pseudocode as follows: DECLARE List : ARRAY[1:200] OF Node The linked list will operate as follows: • Integer variable HeadPointer will store the array index for the first node in the linked list. • The Pointer field of a node contains the index value of the next array element (the next node) in the linked list. • The value 0 is used as a null pointer. (a) (i) State why the value 0 has been selected as the null pointer. ........................................................................................................................................... ..................................................................................................................................... [1] (ii) Give the range of valid values that could be assigned to variable HeadPointer. ..................................................................................................................................... [1] (b) The array List will be initialised so that each node points to the following node. The last node will contain a null pointer. Complete the program flowchart to represent the algorithm for this operation. START END [4] (c) An algorithm outputs the Data field from all nodes in the array List. The order the Data is output should be the same order it is stored in the linked list. Describe the algorithm in four steps. Do not use pseudocode statements in your answer. Step 1 ....................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... Step 2 ....................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... Step 3 ....................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... Step 4 ....................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... [4]
Mark scheme: 3(a)(i) 0 is not a valid array / List index value // No 0th element in the array 1 3(a)(ii) 0 to 200 1 3(b) 4 Mark as follows: MP1 Use of variable as array index and initialisation to 1 / to first element of array MP2 Loop for 199 / 200 iterations MP3 Assign Index+1 to each pointer field in a loop MP4 Assign 0 to 200th pointer field 3(c) One mark per step: 4 MP1 Assign HeadPointer to ThisPointer / Current Pointer // Identify first node using headpointer MP2 Loop the following until ThisPointer value is 0 (zero) / null pointer reached MP3 … Output data (field) from array element at index ThisPointer // Output data (field) of the current node / array element MP4 … Assign pointer field from current array element / index / to ThisPointer / Current Pointer // Assign pointer field from current node to ThisPointer / Current Pointer
Q4 · An examination paper has a maximum of 75 marks
4 An examination paper has a maximum of 75 marks. One of five pass grades (A to E) is assigned, depending on the mark obtained. The lowest mark for a given grade is known as the grade boundary. A program is being written to process examination marks. The five grade boundaries are stored in a global 1D array GB of type INTEGER, for example: Index Value Comment 1 65 The minimum mark for an A grade. 2 57 The minimum mark for a B grade. 3 43 The minimum mark for a C grade. 4 35 The minimum mark for a D grade. 5 27 The minimum mark for an E grade. Any paper that achieves a mark within 2 marks of a grade boundary must be checked. Using the given table, a paper with 45 marks would need to be checked. (a) The pseudocode algorithm to determine whether a paper should be checked is as shown. The mark for the paper is stored in variable Mark. Global variables Mark, Index, Upper and Lower are declared as integers. Complete the pseudocode. FOR Index ← 1 TO ........................................... Lower ← GB[Index] - 2 Upper ← ....................................................... IF Mark ........................................... AND Mark ........................................... THEN OUTPUT "Check this paper" ENDIF NEXT Index [4] (b) An alternative algorithm to determine if a paper needs to be checked uses a global 1D array Check, containing 76 elements of type BOOLEAN. The indices of the array are from 0 to 75 (inclusive), corresponding to the range of possible marks. An element value in Check is TRUE if the index is within 2 marks of a grade boundary. For example, in the case where the C grade boundary is 43 the corresponding part of the Check array would be as follows: Index Value 40 FALSE 41 TRUE 42 TRUE 43 TRUE ← The grade boundary for a C grade 44 TRUE 45 TRUE 46 FALSE (i) The mark for a given paper is stored in variable Mark. Describe how an algorithm would use the Check array to determine whether this paper should be checked. ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ..................................................................................................................................... [2] (ii) A procedure GBInitialise() will initialise the Check array using values from the GB array. Note it can be assumed that the maximum grade boundary value for A is 70 and the minimum value for E is 15. Write pseudocode for the procedure. ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ........................................................................................................................................... ..................................................................................................................................... [6]
Mark scheme: 4(a) One mark per highlighted part: 4 FOR Index 1 TO 5 Lower GB[Index] - 2 Upper GB[Index] + 2 // Lower + 4 IF Mark >= Lower AND Mark <= Upper THEN //IF Mark <= Upper AND Mark >= Lower THEN OUTPUT "Check this paper" ENDIF NEXT Index 4(b)(i) MP1 Use Mark as the index to the Check array // to specify an array 2 element MP2 If value of indexed element is TRUE, then the paper will need to be checked 4(b)(ii) Example:solution 6 PROCEDURE GBInitialise() DECLARE GBIndex, GBMark, ThisIndex : INTEGER FOR ThisIndex 0 TO 75 Check[ThisIndex] FALSE // initialise all values NEXT ThisIndex FOR GBIndex 1 TO 5 GBMark GB[GBIndex] FOR ThisIndex GBMark - 2 TO GBMark + 2 Check[ThisIndex] TRUE //Set GBMark 2 to TRUE NEXT ThisIndex NEXT GBIndex ENDPROCEDURE Mark as follows: MP1 Procedure heading and ending MP2 Initialise Check array to FALSE MP3 Loop through GB array MP4 Extract the GB mark MP5 Loop for 5 elements across GBMark 2 // Check if within GBMark 2 MP6 Assign each element of Check array to TRUE ALTERNATIVE – Example using selection Version 1 FOR ThisIndex 0 TO 75 CASE ThisIndex GB[1] – 2 TO GB[1] + 2 : Check[ThisIndex] TRUE GB[2] – 2 TO GB[2] + 2 : Check[ThisIndex] TRUE GB[3] – 2 TO GB[3] + 2 : Check[ThisIndex] TRUE GB[4] – 2 TO GB[4] + 2 : Check[ThisIndex] TRUE GB[5] – 2 TO GB[5] + 2 : Check[ThisIndex] TRUE OTHERWISE: Check[ThisIndex] FALSE ENDCASE NEXT ThisIndex 4(b)(ii) ALTERNATIVE – Example using selection Version 2 DECLARE ThisIndex, GBIndex : INTEGER DECLARE Lower, Higher : INTEGER FOR ThisIndex 0 TO 75 For GBIndex 1 T0 5 Lower GB[GBIndex] - 2 Higher GB[GBIndex] + 2 IF ThisIndex >= Lower AND ThisIndex <= Higher THEN Check[ThisIndex] TRUE ELSE Check[ThisIndex] FALSE ENDIF NEXT Index NEXT ThisIndex Mark as follows: MP1 Procedure heading and ending MP2 Loop through Check array// loop from 0 to 75 MP3 Attempt at using CASE / Selection structure with five clauses/ five checks for range MP4 Extract GB grade MP5 Compare ThisIndex with each element in GB array 2 MP6 Assign each element of Check array to TRUE if in range or FALSE if not in range
Q5 · A software developer follows a program development life cycle
5 A software developer follows a program development life cycle. The life cycle divides the development process into various stages. (a) The following table lists some development activities. Complete the table by writing the name of the life cycle stage for each activity. Activity Name of life cycle stage A compiler is used. A program that has been released for general use is modified. The dry run method is used. The program structure is specified. [4] (b) A software developer has written modules Test_A() and Test_B(). These have been written but contain errors. These modules are called from several places in the main program and testing of the main program (integration testing) has to stop. Identify a method that can be used to continue testing the main program before the errors in these modules have been corrected and describe how this would work. Method ...................................................................................................................................... Description ................................................................................................................................ ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... [3]
Mark scheme: 5(a) 4 Name of life Activity cycle stage A compiler is be used. Coding A program that has been released for general use Maintenance is modified The dry run method is used. Testing The program structure is specified. Design One mark per row 5(b) One mark for method – two marks for the description 3 MP1 Stub testing MP2 The modules Test_A() and Test_B()are replaced by dummy modules MP3 ... which return a known result // An output statement is displayed when called (to check it works) // gives expected output
Q6 · In some countries, on the third Sunday in March, daylight saving time begins when clocks…
6 In some countries, on the third Sunday in March, daylight saving time begins when clocks move forward by one hour. A module AdjustClock() will take an integer parameter representing a year. The module will return an integer value representing the number of the day in March on which the clocks move forward. For example, the following line of pseudocode would assign DayNumber the value 20: DayNumber AdjustClock(2022) ← Write pseudocode for the function AdjustClock(). Date functions from the insert should be used in your solution. .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .......................................................................................................................................................... .................................................................................................................................................... [7]
Mark scheme: 6 Loop Solution 7 Example solution: FUNCTION AdjustClock(ThisYear : INTEGER) RETURNS INTEGER DECLARE ThisDayNumber, SundayCount : INTEGER DECLARE ThisDate : DATE ThisDayNumber 0 SundayCount 0 REPEAT ThisDayNumber ThisDayNumber + 1 ThisDate SETDATE(ThisDayNumber, 3, ThisYear) IF DAYINDEX(ThisDate) = 1 THEN SundayCount SundayCount + 1 ENDIF UNTIL SundayCount = 3 RETURN ThisDayNumber ENDFUNCTION Mark as follows: MP1 Function heading, parameter, ending and return type MP2 Declare local integer variable that is used to create a date MP3 Loop until 3rd Sunday found MP4 Attempt to use both SETDATE() and DAYINDEX() in a loop MP5 Correctly generate value of type DATE using SETDATE() in a loop MP6 Test if value represents a Sunday using DAYINDEX() in a loop MP7 Increment Sunday count in a loop and initialised correctly before loop MP8 Return day number of third Sunday Max 7 marks Non-loop solution Example solution: FUNCTION AdjustClock(ThisYear : INTEGER) RETURNS INTEGER DECLARE FirstDayIndex: INTEGER DECLARE ThisDate : DATE ThisDate SETDATE(1, 3, ThisYear) FirstDayIndex DAYINDEX(ThisDate) IF FirstDayIndex = 1 THEN ThirdSunday FirstDayIndex + 14 //First day is Sunday ELSE ThirdSunday 23 – FirstDayIndex // Other days ENDIF RETURN ThirdSunday ENDFUNCTION 6 Mark as follows: MP1 Function heading, parameter, ending and return type MP2 Declare local integer variable that is used to hold a day number MP4 Attempt to use both SETDATE() and DAYINDEX() MP5 Correctly generate value of type DATE using SETDATE() for first of March / specific day in March MP6 Test if date represents a Sunday / specific day using DAYINDEX() and calculate third Sunday // Correctly calculate third Sunday for a value returned by DAYINDEX()for one day MP7 Calculate third Sunday for other six days MP8 Return day number of third Sunday Max 7 marks
Q7 · A coffee shop owner wants to introduce a computerised loyalty card system
7 A coffee shop owner wants to introduce a computerised loyalty card system. A programmer discusses the details of the system with the shop owner. (a) Identify the stage of the program development life cycle that this discussion is part of and give a document that will be produced during this stage. Stage ........................................................................................................................................ Document ................................................................................................................................. ................................................................................................................................................... [2] (b) The shop will give each customer a loyalty card that displays a unique customer ID as a bar code. A customer will be able to present their card each time they make a purchase. The system will scan the bar code, calculate points, and add them to the customer’s total. When the customer next makes a purchase and presents their card, they will have the option to exchange points for a discount. The designer decides that this activity will be handled by a new module. Decomposition will be used to break the problem of designing the new module down into sub-problems (sub-modules). Identify four sub-modules that could be used in the design of the new module and describe their use. Sub-module 1 ........................................................................................................................... Use ........................................................................................................................................... ................................................................................................................................................... Sub-module 2 ........................................................................................................................... Use ........................................................................................................................................... ................................................................................................................................................... Sub-module 3 ........................................................................................................................... Use ........................................................................................................................................... ................................................................................................................................................... Sub-module 4 ........................................................................................................................... Use ........................................................................................................................................... ................................................................................................................................................... [4]
Mark scheme: 7(a) One mark per answer: 2 MP1 Analysis MP2 Named document, examples include: • A requirement specification • Definition of System Objectives • List of problems with existing system • Survey results • Feasibility study • Interview notes Max 2 marks 7(b) One mark for name and use 4 Mark as follows: Examples include: Sub-module: ScanCard()/ GetID() Use: Read the barcode from the loyalty card / Get the customer ID from the barcode Sub-module: GetPoints() Use: Get the number of points the customer has Sub-module: ExchangePoints() / UpdateCard() Use: Reduce the number of loyalty points Sub-module: GetDiscount() / CalculateDiscount() Use: Calculate the discount Sub-module: CalculatePoints() Use: Calculate points (following a purchase) Sub-module: UpdatePoints() Use: Update total points a customer has (following a purchase) Sub-module: ShowDiscount() Use: Display the discount Max 4 marks
Q8 · A program is being developed to implement a game for up to six players
8 A program is being developed to implement a game for up to six players. During the game, each player assembles a team of characters. At the start of the game there are 45 characters available. Each character has four attributes, as follows: Attribute Examples Comment Player 0, 1, 3 The player the character is assigned to. The job that the character will perform in the Role Builder, Teacher, Doctor game. The name of the character. Several characters Name Bill, Lee, Farah, Mo may perform the same role, but they will each have a unique name. Skill level 14, 23, 76 An integer in the range 0 to 100, inclusive. The programmer has defined a record type to define each character. The record type definition is shown in pseudocode as follows: TYPE CharacterType DECLARE Player : INTEGER DECLARE Role : STRING DECLARE Name : STRING DECLARE SkillLevel : INTEGER ENDTYPE The Player field indicates the player to which the character is assigned (1 to 6). This field value is 0 if the character is not assigned to any player. The programmer has defined a global array to store the character data, as follows: DECLARE Character : ARRAY[1:45] OF CharacterType At the start of the game all record fields are initialised, and all Player fields are set to 0 The programmer has defined a program module as follows: Module Description Count() • called with two parameters: ○ an integer representing a player ○ a string representing a character role • searches the Character array for characters with the given role that are assigned to the given player • counts the number of assigned characters and sums their total skill level • outputs the result of the search if characters with the given role are found, for example: "Player 3 has 4 characters with the role of Teacher and the total skill level is 65" • if no characters with the given role are found, outputs: "No characters with that role are assigned to this player" (a) Complete the pseudocode for module Count(). PROCEDURE Count(ThisPlayer : INTEGER, ThisRole : STRING) ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ENDPROCEDURE [7] (b) The Character array data has been saved in the text file SaveFile.txt Each line of the file contains one element of the array (one record). New modules are defined: Module Description Extract() • called with two parameters: (already written) ○ a string representing a complete line from the text file ○ an integer representing a field number (see structure below) • returns a string representing the required field Restore() • opens the text file SaveFile.txt • reads lines from the file and assigns values to each record in the Character array using data from each line of the file As a reminder, the record structure is repeated here: TYPE CharacterType DECLARE Player : INTEGER //Field number 1 DECLARE Role : STRING //Field number 2 DECLARE Name : STRING //Field number 3 DECLARE SkillLevel : INTEGER //Field number 4 ENDTYPE Write pseudocode for module Restore(). You must use the module Extract(). ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ................................................................................................................................................... ...................................................................................................................................................
Mark scheme: 8(a) Example solution 7 PROCEDURE Count(ThisPlayer : INTEGER, ThisRole : STRING) DECLARE Index, Num, Total : INTEGER Num 0 Total 0 FOR Index 1 TO 45 IF Character[Index].Player = ThisPlayer AND __ Character[Index].Role = ThisRole THEN Num Num + 1 Total Total + Character[Index].SkillLevel NEXT Index IF Num > 0 THEN OUTPUT "Player ", ThisPlayer, __ " has ", Num, " characters with the role of ", ThisRole, " and the total skill level is ", Total ELSE OUTPUT "No characters with that role are assigned to this player" ENDIF ENDPROCEDURE MP1 Initialisation of local integers for Num and Total MP2 Loop through 45 elements MP3 Attempt to check Player and Role fields in a loop MP4 Correctly compare Player field with parameter in a loop MP5 Correctly compare Role field with parameter in a loop MP6 ... if player and role found, increment Num and sum Skill Total in a loop MP7 Test for any matches after the loop MP8 Both possible OUTPUT statements correctly formed following an attempt at MP6 but outputting one only Max 7 marks 8(b) Example solution: 7 PROCEDURE Restore() DECLARE Index : INTEGER DECLARE Line : STRING OPENFILE "SaveFile.txt" FOR READ FOR Index 1 TO 45 READFILE "SaveFile.txt", Line Character[Index].Player STR_TO_NUM(Extract(Line, 1)) Character[Index].Role Extract(Line, 2) Character[Index].Name Extract(Line, 3) Character[Index].Skill STR_TO_NUM(Extract(Line, 4)) NEXT Index CLOSEFILE "SaveFile.txt" ENDPROCEDURE Mark as follows: MP1 Open the file in read mode and subsequently close MP2 Loop through 45 elements MP3 Read a line from the file in a loop MP4 Attempt to use Extract() in a loop MP5 Correct use of Extract() for all fields in a loop MP6 Use of STR_TO_NUM() on Player and Skill in a loop MP7 Completely correct extraction and assignment of all fields in a loop 8(c) MP1 The Character array / character data can be saved before the 2 program is closed MP2 Allowing the game to continue using the same data / from the point it was saved
What you needed in this session
Cambridge’s own grade thresholds for 2024 Oct/Nov, Paper 2 · Variant 3. A higher threshold means an easier paper — the bar moves with how the cohort did.