Past paper – A Level Computer Science (9618)
Cambridge International AS & A Level · 9618
Computer Science · Paper 23
Oct/Nov 2024 · 9618/23/O/N/24
Answer on paper, open each mark scheme and give yourself marks, then open the Summary.
Question text
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]
ĬÕĊ®Ġ´íÈõÏĪÅĊÝù·þ×
Question text
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]
Ĭ×Ċ®Ġ´íÈõÏĪÅĊÝû·þ×
Question text
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]
ĬÙĊ®Ġ´íÈõÏĪÅĊÞû¶þ×
Question text
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
65
1
The minimum mark for an A grade.
57
2
The minimum mark for a B grade.
43
3
The minimum mark for a C grade.
35
4
The minimum mark for a D grade.
27
5
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.
← 1 TO …
FOR Index
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
FALSE
40
TRUE
41
TRUE
42
← The grade boundary for a C grade
TRUE
43
TRUE
44
TRUE
45
FALSE
46
ĬÙĊ®Ġ´íÈõÏĪÅĊàû¶Ā×
,
,
(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.
…
…
…
…
…
…
…
…
…
Question text
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]
ĬÙĊ®Ġ´íÈõÏĪÅĊÝû¸þ×
Question text
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:
← AdjustClock(2022)
DayNumber
Write pseudocode for the function AdjustClock().
Date functions from the insert should be used in your solution.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [7]
ĬÛĊ®Ġ´íÈõÏĪÅĊÝù¸þ×
Question text
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]
ĬÙĊ®Ġ´íÈõÏĪÅĊßû¸Ā×
Question text
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)
…
…
…
…
…
…
…
…
…
…
…
…
…
…