9618_Specimen_Paper_Answers_Paper_2_(for_examination_from_2021)
9618_Specimen_Paper_Answers_Paper_2_(for_examination_from_2021)
Paper 2
Cambridge International AS & A Level
Computer Science 9618
For examination from 2021
Version 1
In order to help us develop the highest quality resources, we are undertaking a continuous programme
of review; not only to measure the success of our resources but also to highlight areas for
improvement and to identify new development needs.
We invite you to complete our survey by visiting the website below. Your comments on the quality and
relevance of our resources are very important to us.
www.surveymonkey.co.uk/r/GL6ZNJB
Would you like to become a Cambridge International consultant and help us develop
support materials?
www.cambridgeinternational.org/cambridge-for/teachers/teacherconsultants/
UCLES retains the copyright on all its publications. Registered Centres are permitted to copy material from
this booklet for their own internal use. However, we cannot give permission to Centres to photocopy any
material that is acknowledged to a third party, even for internal use within a Centre.
Contents
Introduction ........................................................................................................................................................ 4
Assessment overview ........................................................................................................................................ 5
Question 1 ......................................................................................................................................................... 6
Question 2 ....................................................................................................................................................... 11
Question 3 ....................................................................................................................................................... 13
Question 4 ....................................................................................................................................................... 15
Question 5 ....................................................................................................................................................... 17
Question 6 ....................................................................................................................................................... 20
Question 7 ....................................................................................................................................................... 25
Specimen Paper Answers
Introduction
The main aim of this booklet is to exemplify standards for those teaching Cambridge International AS & A
Level Computer Science 9618, Paper 2: Fundamental Problem-solving and Programming Skills, and to show
examples of very good answers. The questions are from the published Specimen Paper, which contains
seven questions, each consisting of several parts. There are no optional questions. The format of the
Specimen Paper consists of questions and related sub-questions. This may be taken as a guide to actual
examination question papers, although the actual number of questions and sub-questions may alter from
series to series.
In this booklet, we have provided answers for all questions in the Specimen Paper.
The mark schemes for the Specimen Papers are available to download from the School Support Hub at
www.cambridgeinternational.org/support
Past exam resources and other teacher support materials are available on the School Support Hub
www.cambridgeinternational.org/support
Assessment overview
Externally assessed
Many questions require a solution to a problem, which will require the application of problem-solving and
programming skills. Due to the nature of the subject it is likely that there will be several different solutions.
In these cases the mark schemes will reflect the essential components of the solution rather than reference
one specific method.
When writing pseudocode answers, candidates should limit themselves to the list of functions and operators
that are provided in the insert. Whilst it may be tempting to make use of functions or methods that are
available in a certain programming language to provide an easy solution to a given problem, this could
disadvantage those candidates who have not studied that particular language. By using only the defined set
of functions and operators all candidates are given an equal opportunity to provide a correct answer.
Centres are referred to the published pseudocode guide for further information.
Assessment objectives
The assessment objectives (AOs) are:
AO2: Apply knowledge and understanding of the principles and concepts of computer science, including to
analyse problems in computational terms.
AO3: Design, program and evaluate computer systems to solve problems, making reasoned judgements
about these.
Question 1
Examiner comment:
The given values in the table in part (a) are interpreted as follows:
• "Tuesday" is a literal string enclosed by quotation marks and so is of data type STRING
Examiner comment:
The expressions are evaluated as follows:
Row 1
Variable Today contains the string "Tuesday". The MID() function extracts 2 characters from this string
starting from position 3 (i.e. characters 3 and 4) which gives the string "es". Variable Revision contains
the character 'C', so the expression simplifies to:
The & represents the concatenation operator, so this expression evaluates to the string "esCape"
Quotation marks must be used to indicate that the value represents a literal string and not an identifier name.
A common mistake is for these to be omitted.
Row 2
Variable MaxWeight has the value 60.5. Adding this to 4.2 gives 64.7. The INT() function returns the
INTEGER value of the parameter (in this case 64.7) , which is 64.
Row 3
The LENGTH function expects a parameter of type STRING. In this expression a variable of type REAL has
been used, hence the expression is invalid and ERROR should be written, as directed in the question.
Row 4
Variable WeekNumber contains the value 37. The MOD() function returns an INTEGER value representing
the remainder when one number is divided by another using integer arithmetic. In this case 37 divided by 12
gives a remainder of 1.
Row 5
Variable Revision contains the character 'C' which is less than character 'D' so the contents of the first
bracket evaluates to TRUE. Variable LastBatch contains the value TRUE so the contents of the second
bracket evaluates to FALSE. This gives the simplified expression:
Question 1 (b)
2 OUTPUT RIGHT(SomeChars,5)
3 READFILE MyFile, MyChars
4 WRITEFILE MyFile, "Data is " & MyChars
Examiner comment:
The table has been completed correctly, as follows:
Row 1
The assignment of the literal string value to the identifier is an example of a Process
Row 2
The statement involves generating a sub-string by extracting 5 characters from the identifier SomeChars
(the Process) and outputting the resulting sub-string (the Output)
Row 3
The statement reads a line from the file MyFile (the Input) and assigns the value to the identifier Mychars
(the Process).
Row 4
The statement writes a line to the file MyFile (the Output) after first forming a string by concatenating (the
Process) the literal string "Data is " and the value of identifier MyChars.
Question 1 (c)
Examiner comment:
The question specifies a post-condition loop, which implies a REPEAT ... UNTIL construct. The loop
termination condition should be based on the final value required (200). Prior to the loop, the start value
should be assigned to a variable and this variable will be increased by two each time around the loop. Note
that the start value given in the question is not an odd number and so should not be output.
The answer above could be considered to be an "optimised" solution in the sense that the learner has taken
into account the fact that the start value given in the question is not an odd number and modified the initial
value accordingly. They have also realised that adding 2 to an odd number will give the next odd number.
A mistake has been made with the terminating condition, meaning that the final value output would be 197
rather than 199, losing one mark.
MyCount ← 100
REPEAT
IF MOD(MyCount, 2) = 1 // Check for a remainder of 1 when divided by 2 i.e. an
odd number
THEN
OUTPUT MyCount
ENDIF
MyCount ← MyCount + 1
UNTIL MyCount = 200
Note that this alternative solution includes a correct terminating condition and would gain full marks.
Question 2
Examiner comment:
The labelled rectangles represent three program modules. The lines from module Checkout to the other two
modules at the lower level indicate that these two are sub-modules that are called from within Checkout.
The labelled arrows indicate the parameters that are passed between modules; the shaded circle of
parameter C indicates a Boolean value.
In this case, an alternative mark could have been obtained by reference to the module sequence. For
example by answering:
"Module sequence – Checkout calls Card payment and then Account payment"
It is important that candidates read questions carefully to be clear about the scope of the question being
asked. In this case the question refers to the diagram given and not structure charts in general.
Consequently, only features that are present in the given diagram will be awarded a mark. For example,
"iteration" and "selection" are features that may be included in a structure chart but they would not be
acceptable answers as the symbols for these are not included in the given diagram.
Question 2 (b)
Examiner comment:
The example values given for the Data Items indicate the required data types for the parameters. The
single-headed arrows used in the diagram for parameters A and B indicate that these parameters are
passed by value and not by reference. This is the default mechanism and does not need to be explicitly
stated in the function declaration, but use of the BYVALUE keyword would obviously be correct.
The names given to parameters A and B are not important although they must be present and unique and
given the example data items it is expected that they would be given appropriate identifier names. The
parameter order for A and B in the function header is not important.
Question 3
Question 3 (a)
PUSH('Z')
Examiner comment:
There are several different possible ways in which stack operations can function. For clarity, this question
states that the TopOfStack pointer points to the last value added to the stack, in this case the value E in
location 101. Locations 102 to 105 are shown to contain values whereas locations 100 and 99 are shown
as 'empty'. This should be sufficient to indicate to learners that the stack in this case will grow 'upwards'
through decreasing address locations. In this case a 'Push' operation would be pre-decrement operation but
this terminology is not something learners would be expected to be familiar with.
It is intended that the two operations described in the question be applied in sequence to the stack as
shown. If the answer given to the first part is incorrect, then whatever value had been assigned to the
TopOfStack would be carried forward when marking the second part of the question.
Question 3 (b)
The strings are different because one is the reverse of the other. e.g. "CAT" becomes
"TAC"
Examiner comment:
The answer describes the difference between the two strings - that is the strings are in reverse order. In this
case the answer also includes an example, which in itself would be sufficient to gain the first mark.
The answer explains that the reason for this is that a stack operates as a FILO (or LIFO) mechanism.
Question 4
Question 4 (a)
Examiner comment:
In the first two columns the answer correctly names the two possible methods and gives the corresponding
value output in each case. The explanation section requires a more in-depth answer and here the answer
describes the mechanism in each case and also the effect this has on the parameter that is passed.
For each method, a mark is awarded for the name plus the corresponding value output, and two marks for
the explanation.
It is important that the explanation is sufficiently detailed and unambiguous. For example, the statement
"the value is not changed" would not be given a mark as it is not clear which value is being referred to.
Question 4 (b)
Examiner comment:
The answer correctly identifies two features that are contained in the example. In this case the word
'subroutine' would have been an acceptable alternative to 'procedure'.
Question 5
Question 5 (a)
Examiner comment:
The answer requires the definition of a user-defined record type named StockItem that includes the three
fields as required. In the answer above, the data type for each field have been correctly inferred from the
typical values given, but the record type has been named "Stock", rather than "StockItem"
Question 5 (b)
Examiner comment:
The array declaration includes the array size and the data type, but the name of the array has been given as
'StockItem" rather than "Stock".
Question 5 (c)
Examiner comment:
The answer correctly demonstrates how individual data items are accessed using the dot notation.
Question 5 (d)
Examiner comment:
The answer contains one error, but otherwise correctly implements the simple algorithm, the essential
elements of which are as follows:
• A conditional statement to check the price, correctly translating the phrase 'at least' into the
comparison '>='. Note that the expression '> 99' would not be valid in this case as the numbers are
not integer values. For example, information would be output for a stock item with a price of 99.5,
which is not what is required.
• An output statement that includes the required field values and is formatted as required in the
question, but the necessary quotation marks around the literal string "Number in Stock: " have been
omitted.
The answer provides simple 'in-line' pseudocode as the question does not ask for the solution to be provided
as either a procedure or a function.
Question 6
Question 6 (a)
IF NOT (LCaseChar > 1 AND UCaseChar > 1 AND NumChar > 2 AND ReturnFlag)
THEN
ReturnFlag ← FALSE
ENDIF
OUTPUT ReturnFlag
ENDFUNCTION
Examiner comment:
There are many ways of solving this problem – the answer given represents a typical 'straightforward'
solution. There are opportunities for simplification and a solution based on a CASE construct may provide a
more elegant solution but neither of these is a requirement. A functionally correct solution will gain full
marks.
Following the function header and local variable declarations and initialisation, the solution breaks down into
two parts:
A loop is used. Within this loop each character of the given password string is extracted in turn. The
character is compared with the three ranges described by each of the first three rules in the question, and a
separate count is made in the number of characters in each range. If the character is not one of the three
types specified then it is an illegal character and a flag is set. In the answer above, the loop is terminated as
soon as an illegal character is encountered. This is not essential to the solution but would be expected from
a top-grade answer.
Following the loop, the four rules given are tested via an IF statement. This assigns a Boolean value to the
variable, which is then returned.
• The loop does not check the final character of the string. The condition should be:
n <= LENGTH(Pass)
The available mark scheme points are shown below. For this answer, marks have been awarded for the
points that have not been crossed through. (Note that the question is for a maximum of 9 marks, but there
are 10 possible mark points)
Examiner comment:
The answer satisfies the three rules as it contains:
• 4 uppercase alphabetic characters
• 4 lowercase alphabetic characters
• 3 numeric characters
• no non-alphanumeric characters.
Note: The question asks simply for the password, rather than for a STRING value, so double quotation
marks are not required. These would be ignored if present.
Password: Pword123
Reason: only one upper-case alphabetic characters – should be at least two
Password: PASSword12
Reason: only two numeric characters – should be at least three
Password: PASSw-123
Reason: contains a non-alphanumeric character
Examiner comment:
Each password should break a different rule, and each password should break only one rule. A password
that breaks more than one rule would be of limited use for test purposes.
The final password is incorrect. Although it contains an illegal character it also contains an incorrect number
of lowercase alphabetic characters.
Examiner comment:
The correct term has been given.
Examiner comment:
The answer addresses the first of the required two points, which are that the function can be tested before it
is fully written.
For the second mark, the answer would need to say how this could be achieved. For example:
The function contents are replaced with simple code to return a fixed value or to
output a message.
Question 7
Question 7
CLOSEFILE "LoginFile.txt"
ENDPROCEDURE
Examiner comment:
The scenario description is straightforward and although different solutions may include minor variations, all
will require the following features:
• The pseudocode will be contained within a procedure named LogEvents, which has a header and
an end statement
• A loop is required to search through the array. A loop variable (ArrayIndex above), of type
INTEGER is necessary as this will be used to index individual element values within the array
• The file must be opened in APPEND mode in order to add data to the end of the existing file
• Within the loop, each array element needs to be checked to check whether it contains the string
"Empty"
• If an array element does not contain the value "Empty" then the value is written to the file
• After the loop ends, loop the file is closed
• The check for an unused elements uses an empty string rather than te value "Empty"
The available mark scheme points are shown below. For this answer, marks have been awarded for the
points that have not been crossed through.
4. Correct loop
5. Extract data from array in a loop
6. Check for unused element in a loop
7. Write data to file in a loop
8. Close the file outside the loop