Cambridge International AS & A Level: Computer Science 9618/21
Cambridge International AS & A Level: Computer Science 9618/21
INSERT 2 hours
INFORMATION
*8416100942-I*
DC (PQ) 329349/3
-m
An error will be generated if a function call is not properly formed or if the parameters are of an incorrect
type or an incorrect value.
If the string begins with the '–' character, the returned value will be negative.
at
-m
am
Numeric functions
Date functions
Date format is assumed to be DD/MM/YYYY unless otherwise stated.
Operators
An error will be generated if an operator is used with a value or values of an incorrect type.
Comparison operators
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
m
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
co
Cambridge Assessment International Education is part of Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.
am
2 hours
INSTRUCTIONS
● Answer all questions.
● Use a black or dark blue pen.
● Write your name, centre number and candidate number in the boxes at the top of the page.
● Write your answer to each question in the space provided.
● Do not use an erasable pen or correction fluid.
● Do not write on any bar codes.
● You may use an HB pencil for any diagrams, graphs or rough working.
● Calculators must not be used in this paper.
INFORMATION
● The total mark for this paper is 75.
● The number of marks for each question or part question is shown in brackets [ ].
● No marks will be awarded for using brand names of software packages or hardware.
● The insert contains all the resources referred to in the questions.
DC (PQ/CGW) 329348/4
-m
Refer to the insert for the list of pseudocode functions and operators.
(a) The following table shows four valid pseudocode assignment statements.
Complete the table by giving an appropriate data type to declare each of the variables A, B, C
and D.
Variable Value
Sorted False
Tries 9
ID "ZGAC001"
Complete the table by evaluating each expression, using the example values.
Expression Evaluates to
Tries MOD 4
TO_LOWER(MID(ID, 3, 1))
(c) The variable names A, B, C and D in part (a) are not good programming practice.
...........................................................................................................................................
..................................................................................................................................... [1]
(ii) Identify one problem that these variable names might cause.
...........................................................................................................................................
..................................................................................................................................... [1]
(iii) The choice of suitable variable names is one example of good programming practice.
...........................................................................................................................................
..................................................................................................................................... [1]
m
co
e.
at
-m
am
START
INPUT A, B
Yes
No
m
co
e.
END
at
-m
[5]
am
Following the input of ThisSequence the revised algorithm will extract the pairs of numbers.
Describe the variable ThisSequence and how the numbers are extracted.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]
m
co
e.
at
-m
am
3 The diagram shows an Abstract Data Type (ADT) representation of a linked list after data items
have been added.
PS
Df Dc Db Dy Ø
PF
Fg Fh Fm Fw Ø
(a) Describe the linked list immediately after initialisation, before any data items are added.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
m
co
e.
at
-m
am
(b) A program will be written to include a linked list to store alphanumeric user IDs.
The design uses two variables and two 1D arrays to implement the linked list.
Each array element contains data of a single data type and not a record.
................................................................................................................................................. .
m
co
e.
at
-m
am
• total the element values in odd index locations (1, 3, 5 ... 97, 99)
• total the element values in even index locations (2, 4, 6 ... 98, 100)
• return one of three strings ‘Odd’, ‘Even’ or ‘Same’ to indicate which total is the greater, or
whether the totals are the same.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
m
co
.................................................................................................................................................... [6]
e.
at
-m
am
BLANK PAGE
m
co
e.
at
-m
am
5 A global 1D array of strings contains three elements which are assigned values as shown:
Data[1] "aaaaaa"
Data[2] "bbbbbb"
Data[3] "cccccc"
Result "****"
CASE OF C
'X' : Result TO_UPPER(Data[Index])
'Y' : Result TO_LOWER(Data[Index])
'Z' : Result "**" & Data[Index]
ENDCASE
Data[Index] LEFT(Result, L)
NEXT Count
ENDPROCEDURE
m
co
e.
at
-m
am
(a) Complete the trace table by dry running the procedure when it is called as follows:
CALL Process("X3Y2W4")
[6]
(b) The procedure is to be modified. If variable C is assigned a value other than 'X', 'Y' or 'Z',
then procedure Error() is called and passed the value of variable C as a parameter.
..................................................................................................................................... [1]
..................................................................................................................................... [1]
m
co
e.
at
-m
am
6 Three points on a grid form a triangle with sides of length A, B and C as shown in the example:
10
9
8
7
6
5 B C
4
3
2 A
1
x
0 1 2 3 4 5 6 7 8 9 10
A triangle is said to be right-angled if the following test is true (where A is the length of the longest
side):
A2 = B2 + C2
You can calculate A2, B2 and C2 by using the coordinates of the endpoints of each line.
10
9
8
7
P2
6 (x2, y2)
5 B
4
3
P1
2 (x1, y1)
1
x
0 1 2 3 4 5 6 7 8 9 10
The endpoints, P1 and P2, have the coordinates (3, 2) and (6, 6).
In this example:
B2 = (3 − 6)2 + (2 − 6)2
m
B2 = (–3)2 + (–4)2
co
B2 = 9 + 16
e.
at
B2 = 25
-m
am
• take three sets of integers as parameters representing the coordinates of the three
endpoints that form a triangle
• return TRUE if the endpoints form a right-angled triangle, otherwise return FALSE.
In pseudocode, the operator ‘^’ represents an exponent, which is the number of times a value
is multiplied by itself. For example, the expression Value2 may be written in pseudocode as
Value ^ 2
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
ENDFUNCTION
[6]
m
co
e.
at
-m
am
(b) The test used to check if a triangle is right-angled can be written in two ways:
A2 = B2 + C2
or
A = √(B2 + C2)
The symbol √ represents the square root operation. For example, √81 = 9
A new function SQRT() is written to perform the square root operation. The function takes an
integer number as a parameter and returns a positive real value representing the square root
of the number.
During testing it is found that the SQRT() function returns a value that is only accurate to
4 decimal places.
For example, SQRT(25) returns 5.0000125 rather than the correct value of 5.0
The function IsRA() from part (a) is modified to use the new SQRT() function to test if a
triangle is right-angled.
Describe a problem that might occur when using the modified IsRA() function and suggest
a solution that still allows the SQRT() function to be used.
Problem ....................................................................................................................................
...................................................................................................................................................
Solution .....................................................................................................................................
...................................................................................................................................................
[2]
m
co
e.
at
-m
am
BLANK PAGE
m
co
e.
at
-m
am
7 A fitness club has a computerised membership system. The fitness club offers a number of
different exercise classes.
The following information is stored for each club member: name, home address, email address,
mobile phone number, date of birth and the exercise(s) they are interested in.
(a) When an exercise class is planned, a new module will send personalised text messages to
each member who has expressed an interest in that exercise. Members wishing to join the
class send a text message back. Members may decide not to receive future text messages
by replying with the message ‘STOP’.
...........................................................................................................................................
..................................................................................................................................... [1]
(ii) Identify three items of information that will be required by the new module.
Justify your choices with reference to the given scenario.
Justification .......................................................................................................................
...........................................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
[3]
(iii) Identify two operations that would be required to process data when the new module
receives a text message back from a member.
Operation 1 .......................................................................................................................
...........................................................................................................................................
Operation 2 .......................................................................................................................
...........................................................................................................................................
m
[2]
co
e.
at
-m
am
Update
A
P2
T1
Name P1
(i) Explain the meaning of the diamond symbol (labelled with the letter A) in the chart.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
(ii) Write the pseudocode module headers for Sub-A and Sub-B.
Sub-A
...........................................................................................................................................
...........................................................................................................................................
Sub-B
...........................................................................................................................................
...........................................................................................................................................
[4]
m
co
e.
at
-m
am
The process is split into a number of stages. Each stage performs a different task and creates a
new file named as shown:
Module Description
DeleteComment() • called with a parameter of type string representing a line of
pseudocode from a student’s project file
• returns the line after removing any comments
Note on comments:
A comment starts with two forward slash characters and includes all the
remaining characters on the line.
The following example shows a string before and after the comment has
been removed:
m
co
e.
at
-m
am
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
ENDFUNCTION
[8]
m
co
e.
at
-m
am
Module Description
Stage_1() • called with a parameter of type string representing a student name
• creates a new stage 1 file
• copies each line from the student’s project file to the stage 1 file after
removing any comment from each line
• does not write blank lines to the stage 1 file
• returns the number of lines written to the stage 1 file
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
m
co
...................................................................................................................................................
e.
at
-m
...................................................................................................................................................
am
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
m
co
e.
at
-m
am
BLANK PAGE
m
co
e.
at
-m
am
BLANK PAGE
m
co
e.
at
-m
am
BLANK PAGE
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
m
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
co
Cambridge Assessment International Education is part of Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.
am