Computer Science (9618) · May/June 2021 · Mark scheme 21

Cambridge Computer Science (9618) mark scheme for paper 21, May/June 2021 — 9618/21/M/J/21, file 9618_s21_ms_21.pdf.

Advertisement
Loading the paper…
Text of this paper

Cambridge International AS & A Level
COMPUTER SCIENCE

9618/21

Paper 2 Problem Solving & Programming Skills

May/June 2021

MARK SCHEME
Maximum Mark: 75

Published

This mark scheme is published as an aid to teachers and candidates, to indicate the requirements of the
examination. It shows the basis on which Examiners were instructed to award marks. It does not indicate the
details of the discussions that took place at an Examiners’ meeting before marking began, which would have
considered the acceptability of alternative answers.
Mark schemes should be read in conjunction with the question paper and the Principal Examiner Report for
Teachers.
Cambridge International will not enter into discussions about these mark schemes.
Cambridge International is publishing the mark schemes for the May/June 2021 series for most Cambridge
IGCSE™, Cambridge International A and AS Level components and some Cambridge O Level components.

This document consists of 16 printed pages.
© UCLES 2021

[Turn over

9618/21

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

May/June 2021

Generic Marking Principles
These general marking principles must be applied by all examiners when marking candidate answers.
They should be applied alongside the specific content of the mark scheme or generic level descriptors
for a question. Each question paper and mark scheme will also comply with these marking principles.
GENERIC MARKING PRINCIPLE 1:
Marks must be awarded in line with:
•
•
•

the specific content of the mark scheme or the generic level descriptors for the question
the specific skills defined in the mark scheme or in the generic level descriptors for the question
the standard of response required by a candidate as exemplified by the standardisation scripts.

GENERIC MARKING PRINCIPLE 2:
Marks awarded are always whole marks (not half marks, or other fractions).
GENERIC MARKING PRINCIPLE 3:
Marks must be awarded positively:
•
•
•
•
•

marks are awarded for correct/valid answers, as defined in the mark scheme. However, credit
is given for valid answers which go beyond the scope of the syllabus and mark scheme,
referring to your Team Leader as appropriate
marks are awarded when candidates clearly demonstrate what they know and can do
marks are not deducted for errors
marks are not deducted for omissions
answers should only be judged on the quality of spelling, punctuation and grammar when these
features are specifically assessed by the question as indicated by the mark scheme. The
meaning, however, should be unambiguous.

GENERIC MARKING PRINCIPLE 4:
Rules must be applied consistently, e.g. in situations where candidates have not followed
instructions or in the application of generic level descriptors.
GENERIC MARKING PRINCIPLE 5:
Marks should be awarded using the full range of marks defined in the mark scheme for the question
(however; the use of the full mark range may be limited according to the quality of the candidate
responses seen).
GENERIC MARKING PRINCIPLE 6:
Marks awarded are based solely on the requirements as defined in the mark scheme. Marks should
not be awarded with grade thresholds or grade descriptors in mind.

© UCLES 2021

Page 2 of 16

9618/21

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
1(a)

May/June 2021

Answer

Marks
4

Example
value

Explanation

Variable name

Data type

"Wong"

The preferred name of the
member joining the
football club

MemberName

STRING

FALSE

A value to indicate
whether an existing
member of the club lives
at the same address

FamilyMember

BOOLEAN

19/02/1983

When the member joined
the football club

StartDate

DATE

1345

The number of points a
member has earned.
Members of the club earn
points for different
activities.

Points

INTEGER

One mark for each appropriate variable name plus data type
1(b)

Statement

Error

Result ← 2 & 4

Should be arithmetic
operator (not &) // 2 and 4
should be CHAR / STRING

SubString ← MID("pseudocode", 4, 1)

NO ERROR

IF x = 3 OR 4 THEN

Not Boolean values /
incorrect operator //
Condition incorrect

Result ← Status AND INT(X/2)

INT(X/2) doesn't evaluate
to a boolean value /
incorrect operator

Message ← "Done" + LENGTH(MyString)

Can’t add string to number /
"Done" is not a number

One mark for each row

© UCLES 2021

Page 3 of 16

5

9618/21

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
1(c)

Answer

Marks
3

Structure:
• Record
Justification:
• Allows different data types
• to be stored under one identifier
Mark as follows:
One mark for Structure
Two marks for justification.
Alternative
• Two (1D) arrays
• One of string, one of integer
• Where same index links the name with the score

© UCLES 2021

May/June 2021

Page 4 of 16

9618/21

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question

Answer

May/June 2021

Marks
5

2(a)

One mark for:
1
2
3
4
5
2(b)

All four boxes correctly labelled and positioned
Selection diamond (only on UpdateLoan and no iteration arrows)
Parameters to and from LoanExtend()
Parameters to and from CheckReserve()
Parameters to and from LoanReturn()

PROCEDURE LoanReturn (LoanID, BookID : STRING,
BYREF Fine : REAL)
One mark for each underlined part

© UCLES 2021

Page 5 of 16

2

9618/21

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
2(c)

Answer
Example solution:

Marks
6

One mark for each functional group as listed below:

© UCLES 2021

May/June 2021

Page 6 of 16

9618/21

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
2(c)

Answer

Marks

Explanation of mark points:
1 Initialise MAX to first value input
2 Set Total to zero
3 Input 49 more values (or 50 values in total)
4 Sum all values input
5 Set new MAX when Input value > MAX in a loop
6 Sum all but largest (or subtract MAX from total), calculate and output
average

Question
3(a)(i)

May/June 2021

Answer

2

One mark per bullet point:
•
•
•

Marks

Data from the arrays is written to the files at the end of the day / before the
program is terminated / computer is switched off
Data can then be read from the files at the start of the next day and written to
/ stored in the arrays
No need to (re-)enter the data manually // only need to enter data once

Note: Max 2 marks
3(a)(ii)

•

3(a)(iii)

One mark per bullet point:
•
•

The data is retained when the program is terminated / after the computer is
switched off // data is stored permanently // non-volatile storage

2

Data items are combined to form a single string / saved as a single line in the
file
Data items are separated by a special character // make each data item a
fixed length

ALTERNATIVE:
•
•

© UCLES 2021

1

Convert all data items / 'number of people' to strings
Consecutive / each line stores a separate data item

Page 7 of 16

9618/21

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
3(b)

Answer
PROCEDURE Preview (ThisFile : STRING)
DECLARE LineNum : INTEGER
DECLARE ThisLine : STRING

OPENFILE ThisFile FOR READ
IF EOF(ThisFile) THEN
OUTPUT “Warning Message”
ELSE
LineNum ← 1
WHILE LineNum < 6 AND NOT EOF(ThisFile)
READFILE Thisfile, ThisLine
OUTPUT ThisLine
LineNum ← LineNum + 1
ENDWHILE
ENDIF
CLOSEFILE ThisFile
ENDPROCEDURE
Marks as follows:
1
2
3
4
5

© UCLES 2021

Procedure heading (including parameter) and ending
File OPEN and subsequently CLOSE
Check if file is empty and output a warning message if it is
Conditional Loop
Output line (including blank lines) and read next line in a loop

Page 8 of 16

May/June 2021

Marks
5

9618/21

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
4(a)

May/June 2021

Answer
Name

Marks

Flag

Index

NewName

TRUE

1

""

ThisChar

"∇in∇a∇∇Cup"

'∇'
"∇"
2
FALSE

'i'
"∇I"

3

'n'
"∇In"

4
TRUE

'∇'
"∇In∇"

5
FALSE

'a'
"∇In∇A"

6
TRUE

'∇'
"∇In∇A∇"

7

'∇'
"∇In∇A∇∇"

8
FALSE

'C'
"∇In∇A∇∇C"

9

'u'
"∇In∇A∇∇Cu"

10

'p'
"∇In∇A∇∇Cup"

FALSE

11

"∇In∇A∇∇Cup"

'p'

Mark as follows:
• One mark for each of columns 2 to 5 (condone missing final 11)
• One mark for final row all correct (including final 11)

© UCLES 2021

Page 9 of 16

5

9618/21

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
4(b)

Answer
Loop structure: A count-controlled loop

May/June 2021

Marks
2

Justification: The number of iterations is known
One mark per point
4(c)(i)

A couple of solutions:
24

1

ThisChar ← LCASE(MID(Name, Index, 1)

ALTERNATIVE:
31

NewName ← NewName & LCASE(ThisChar)

Ignore line number
4(c)(ii)

One mark for each:

2

Line number: 26
New position: Move to after line 27 / line 28

© UCLES 2021

Page 10 of 16

9618/21

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
5

May/June 2021

Answer
PROCEDURE
DECLARE
DECLARE
DECLARE

Sort()
Temp : INTEGER
NoSwaps : BOOLEAN
Boundary, Row, Col : INTEGER

Marks
8

Boundary ← 999
REPEAT
NoSwaps ← TRUE
FOR Row ← 1 TO Boundary
IF Result[Row, 2] > Result[Row + 1, 2] THEN
FOR Col ← 1 TO 2
Temp ← Result [Row, Col]
Result [Row, Col] ← Result [Row + 1, Col]
Result [Row + 1, Col] ← Temp
NEXT Col
NoSwaps ← FALSE
ENDIF
NEXT J
Boundary ← Boundary - 1
UNTIL NoSwaps = TRUE
ENDPROCEDURE
Mark as follows:
1
2
3
4
5
6
7
8

Outer loop
Inner loop
Correct comparison in a loop
Correct swap of col1 array elements in a loop
Correct swap of col2 array elements in a loop (via loop or separate
statements)
'NoSwap' mechanism: Conditional outer loop including flag reset
'NoSwap' mechanism: Set flag in inner loop to indicate swap
Reducing Boundary in the outer loop

Question
6(a)

Answer

4

One mark per point:
1
2
3
4
5
6

Check for a free node
Search for correct insertion point
Assign data value B to first node in free list / node pointed to by start
pointer of free list
Pointer from A will be changed to point to node containing B (instead of
C)
Pointer from B will be changed to point to node containing C
Start pointer in free list moved to point to next free node

Note: max 4 marks

© UCLES 2021

Marks

Page 11 of 16

9618/21

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
6(b)

May/June 2021

Answer

2

One mark per point:
•
•

An array (1D) to store the data and a second array (1D) to store the pointers
An (integer) variable to hold the start pointer and an (integer) variable to store
the next free pointer

ALTERNATIVE:
•
•

© UCLES 2021

Marks

Define a record type comprising a data element and a pointer and declare an
array (1D) of this type
An integer variable to hold the start pointer and an integer variable to store
the next free pointer

Page 12 of 16

9618/21

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
7(a)

May/June 2021

Answer
FUNCTION GetStart (WordNum : INTEGER) RETURNS INTEGER
DECLARE Index, ThisPos, NumFound : INTEGER
DECLARE ThisChar : Char
CONSTANT SPACECHAR = ' '
Index ← -1
Numfound ← 0
ThisPos ← 1
IF WordNum = 1 THEN // if looking for word 1...
Index ← 1
// Word 1 always starts at index
// position 1
ELSE
// Otherwise start counting spaces...
WHILE ThisPos <= LENGTH(FNString) AND Index = -1
ThisChar ← MID(FNString, ThisPos, 1)
IF ThisChar = SPACECHAR THEN
NumFound ← NumFound + 1
IF NumFound = WordNum - 1 THEN
Index ← ThisPos + 1 // the start of the
// required word
ENDIF
ENDIF
ThisPos ← ThisPos + 1
ENDWHILE
ENDIF
RETURN Index
ENDFUNCTION
1 mark for each of the following:
1
2
3
4
5
6
7
8

Function heading, including return type and function end
Loop counting spaces until word found or end of FNString
extract a character from FNString in a loop
compare with SPACECHAR and increment count if equal in a loop
compare count with WordNum - 1 (depending on initialisation
value) in a loop
if equal then set flag or Index to ThisPos + 1 in a loop
Return Index (correctly in all cases / following a reasonable attempt)
Works for special case when looking for word 1

Note: Max 7 marks

© UCLES 2021

Page 13 of 16

Marks
7

9618/21

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
7(b)

May/June 2021

Answer
Marks awarded for any reference to each of the following steps of the algorithm:
1
2
3
4
5

Mention of variable for use as array index
Use of a loop (to check through the array)
If word is the same as the current array element then return FALSE /
set flag
If word not already in array, loop to find unused element (second loop)
Store word in unused element and return TRUE, otherwise return
FALSE

VARIATION:
1
2
3
4
5

Mention of variable for use as array index
Use of a loop (to check through the array)
Save index of (first) unused element found
If word is the same as the current array element then return FALSE /
set flag
If word not already in array and unused element available, store word in
unused element and return TRUE otherwise return FALSE

Note: Max 4 marks

© UCLES 2021

Page 14 of 16

Marks
4

9618/21

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
7(c)

May/June 2021

Answer
FUNCTION GetWord (Index : INTEGER) RETURNS STRING
DECLARE
DECLARE
DECLARE
DECLARE

NextWord : STRING
Done : BOOLEAN
ThisChar : CHAR
Index : INTEGER

CONSTANT SPACECHAR = ' '
NextWord ← ""
Done ← FALSE
REPEAT
ThisChar ← MID(FNString, Index, 1)
IF ThisChar <> SPACECHAR THEN
NextWord ← NextWord & ThisChar // build up NextWord
ENDIF
IF ThisChar = SPACECHAR OR Index = LENGTH(FNString) THEN
Done ← TRUE
ENDIF
Index ← Index + 1
UNTIL Done = TRUE
RETURN NextWord
ENDFUNCTION
1 mark for each of the following:
1
2
3
4
5

© UCLES 2021

Conditional loop
Extract char from FNString and compare with SPACECHAR in a
loop
Concatenate with NextWord if not SPACECHAR in a loop
Exit loop when SPACECHAR encountered or when end of FNString
reached
Return NextWord (after reasonable attempt at forming, and must have
been initialised)

Page 15 of 16

Marks
5

9618/21

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
7(c)

May/June 2021

Answer
The ‘length and substring’ solution:
FUNCTION GetWord (Index : INTEGER) RETURNS STRING
DECLARE Done : BOOLEAN
DECLARE ThisChar : CHAR
DECLARE Index, NextPos : INTEGER
CONSTANT SPACECHAR = ' '
Done ← FALSE
NextPos ← Index // must be at least one character in
// the required word
REPEAT
ThisChar ← MID(FNString, NextPos, 1)
IF ThisChar = SPACECHAR OR NextPos =
LENGTH(FNString) THEN
Done ← TRUE
ELSE
NextPos ← NextPos + 1
ENDIF
UNTIL Done = TRUE
IF NextPos = LENGTH(FNString) THEN
NextPos ← NextPos - 1 // special case when last word
ENDIF
RETURN MID(FNString, Index, NextPos - Index)
ENDFUNCTION
1 mark for each of the following:
1
2
3
4
5

© UCLES 2021

Conditional loop
...extract char from FNString and compare with SPACECHAR in a
loop
.. increment count if word continues
Exit loop when SPACECHAR encountered or when end of FNString
reached
Apply substring function and Return

Page 16 of 16

Marks

Advertisement