Computer Science (9608) · May/June 2019 · Mark scheme 21
Cambridge Computer Science (9608) mark scheme for paper 21, May/June 2019 — 9608/21/M/J/19, file 9608_s19_ms_21.pdf.
Text of this paper
www.dynamicpapers.com
Cambridge Assessment International Education
Cambridge International Advanced Subsidiary and Advanced Level
COMPUTER SCIENCE
9608/21
Paper 2 Written Paper
May/June 2019
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 2019 series for most
Cambridge IGCSE™, Cambridge International A and AS Level and Cambridge Pre-U components, and
some Cambridge O Level components.
This document consists of 11 printed pages.
© UCLES 2019
[Turn over
9608/21
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2019
PUBLISHED
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 2019
Page 2 of 11
9608/21
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2019
PUBLISHED
Question
1(a)(i)
Answer
Marks
Construct: Assignment
Pseudocode example: Answer ← "YES"
4
Construct: Selection
Pseudocode example: IF X = 3 THEN OUTPUT "HELLO"
Construct: Repetition / Iteration
Pseudocode example: FOR N ← 1 to 100
One mark for construct
One mark for pseudocode example
Maximum 4 marks
1(a)(ii)
Pseudocode statement
Input
Temp ← SensorValue *
Factor
Process
Output
4
3
WRITEFILE "LogFile.txt",
TextLine
3
WRITEFILE "LogFile.txt",
MyName & MyIDNumber
READFILE
"AddressBook.txt",
NextLine
3
3
3
(3)
One mark per correct row
1(b)(i)
Expression
MID(Title, 5, 3) & RIGHT(Author, 3)
INT(WeightEach * PackSize)
PackSize >= 4 AND WeightEach < 6.2
"tripod"
24
FALSE
LEFT(Author, ASC(Version) - 65)
"Er"
RIGHT(Title, (LEN(Author) – 6))
"hetti"
Quotes must be present
Must be capital E in row 4
© UCLES 2019
Evaluates to
Page 3 of 11
5
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2019
PUBLISHED
9608/21
Question
Answer
1(b)(ii)
Variable
Data type
Tile
STRING
Version
CHAR
PackSize
INTEGER
WeightEach
REAL
Paperback
BOOLEAN
Marks
5
One mark per data type
1(c)
Data is chosen:
• to test that the program does what it is supposed to do / to check that
the results are as expected
• to use known valid, boundary and erroneous values
Question
Answer
2
Marks
2(a)
Type: Conditional
Explanation: The number of iterations is not known / dependent on a
condition
2
2(b)
One mark per bullet point to max 3
• Functions / Procedures / Modules / subtasks
• Parameters
• Variable / constant declaration / assignment / Data types
• Input / Output
• Arithmetic / logic operations
• Classes / Objects
3
2(c)
One mark for:
• A CASE structure
3
Max 2 for remaining points:
•
•
•
•
© UCLES 2019
Selecting on / using variable X
Calling ProcA if X = 15
Assigning a value of 0 to Y if X = 20 and assign 99 to Y if X = 25
Calling ProcError if no match (previous conditions not satisfied) // Call
ProcError if x = NONE
Page 4 of 11
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2019
PUBLISHED
9608/21
Question
3(a)
Answer
TotalValue ← 0
ZeroCount ← 0
Marks
7
FOR Index ← 1 TO 100
TotalValue ← TotalValue + Result[Index]
IF Result[Index] = 0.0
THEN
ZeroCount ← ZeroCount + 1
ENDIF
ENDFOR
OUTPUT "The average is ", (TotalValue / 100)
OUTPUT "The number of elements with a zero value is ",
ZeroCount
One mark for each of the following:
1
2
3
4
5
6
7
3(b)
Both initialisations
Loop 100 times
Adding individual element to TotalValue in a loop
Check if element value is zero in a loop
If so increment ZeroCount in a loop
Average is calculated after the loop
Both OUTPUT statements, including message and variables
PROCEDURE ScanArray (BYREF AverageValue: REAL, _
BYREF ZeroCount: INTEGER, ArrayName : ARRAY)
One mark for each underlined part
Names unimportant but first two parameters must be BYREF
© UCLES 2019
Page 5 of 11
4
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2019
PUBLISHED
9608/21
Question
Answer
Marks
4(a)(i)
6
Index
AfterSpace
NextChar
FALSE
""
1
2
NewString
TRUE
'X'
"X"
'∇'
"X∇"
3
'∇'
4
'∇'
5
FALSE
'Y'
"X∇Y"
6
TRUE
'∇'
"X∇Y∇"
7
FALSE
‘a’
"X∇Y∇a"
8
'n'
"X∇Y∇an"
9
'd'
"X∇Y∇and"
'∇'
"X∇Y∇and∇"
10
TRUE
11
12
'∇'
FALSE
'Z'
"X∇Y∇and∇Z"
One mark for each area as outlined. If no row marks then mark by column
for columns 2, 3 and 4
4(a)(ii)
To remove repeated space characters
1
4(a)(iii)
•
•
2
© UCLES 2019
All leading spaces / spaces at the beginning
will be removed (from the input string)
Page 6 of 11
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2019
PUBLISHED
9608/21
Question
4(b)
Answer
DECLARE Code : ARRAY[1:500, 1:4] OF STRING
DECLARE RowIndex : INTEGER
DECLARE ColIndex : INTEGER
Marks
4
FOR RowIndex ← 1 TO 500
FOR ColIndex ← 1 TO 4
Code[RowIndex, ColIndex] ← "Empty"
ENDFOR
ENDFOR
One mark for each of the following:
1
2
3
4
Array declaration
Additional local variable
Nested loops
Array element assignment within the inner loop
RowIndex and ColIndex can be interchangeable
4(c)
© UCLES 2019
Adaptive Maintenance
1
Page 7 of 11
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2019
PUBLISHED
9608/21
Question
Answer
5(a)
•
•
•
5(b)
PROCEDURE TestRand()
Saves development time / no need to write it / can’t write it«
Pre-compiled and tested / Increased reliability / reduces chance of error
Is available to all programs
DECLARE
DECLARE
DECLARE
DECLARE
DECLARE
MyArray : ARRAY [1:50] OF BOOLEAN
Attempts : INTEGER
NumFound : INTEGER
ThisRndNumber : INTEGER
Index : INTEGER
NumFound ← 0
Attempts ← 0
WHILE NumFound < 50
ThisRndNumber ← 1 + INT(RAND(50))
Attempts ← Attempts + 1
IF MyArray[ThisRndNumber] = FALSE
THEN
MyArray[ThisRndNumber] ← TRUE
NumFound ← NumFound + 1
ENDIF
ENDWHILE
OUTPUT "Number of calls to RAND() was ", Attempts
ENDPROCEDURE
1 mark for each of the following:
© UCLES 2019
3
8
FOR Index ← 1 TO 50
Myarray[Index] ← FALSE
ENDFOR
1
2
3
4
5
6
7
8
Marks
Declaration of array of 50 elements
Loop to initialise array
Conditional loop stopping when all numbers generated
Generate a random integer in the range 1 to 50 in a loop
Count each call to RND() in a loop
check if the number has already been generated in a loop
if true, record as generated in a loop
Output a message plus the Attempts outside a loop
Page 8 of 11
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2019
PUBLISHED
9608/21
Question
6(a)
Answer
One mark for each of:
1
2
3
6(b)
3
To make a more manageable / understandable solution
Subroutine may be (independently) tested and debugged
Program is easier to maintain
'Pseudocode' solution included here for development and clarification of
mark scheme.
Programming language example solutions appear in the Appendix.
FUNCTION FindCD(SearchCDArtist : STRING,
SearchCDTitle : STRING) RETURNS STRING
DECLARE
DECLARE
DECLARE
DECLARE
CDTitle : STRING
CDArtist : STRING
CDLocation : STRING
Location : STRING
Location ← ""
OPENFILE "MyCDs.txt" FOR READ
WHILE NOT EOF ("MyCDs.txt") AND Location = ""
READFILE "MyCDs.txt", CDArtist
READFILE "MyCDs.txt", CDTitle
READFILE "MyCDs.txt", CDLocation
IF SearchCDArtist = CDArtist AND
SearchCDTitle = CDTitle
THEN
Location ← CDLocation
ENDIF
ENDWHILE
CLOSEFILE("MyCDs.txt")
RETURN Location
ENDFUNCTION
One mark for each of the following:
1
2
3
4
5
6
7
8
© UCLES 2019
Marks
Function header and close (where appropriate), including parameters
Declaration of local STRING variables for CDArtist and CDTitle
OPEN and CLOSE file for reading (Allow MyCDs or MyCDs.txt)
(WHILE) loop checking for EOF
read three lines from file in a loop
compare search values with file values in a loop«
«If true, set Location and exit loop in a loop
Return Location
Page 9 of 11
8
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2019
PUBLISHED
9608/21
Program Code Example Solutions
Q6 (b) (i): Visual Basic
Function FindCD(SearchCDArtist As String, SearchCDTitle As String) As
String
Dim
Dim
Dim
Dim
CDTitle As String
CDArtist As String
CDLocation As String
Location As String
Location = ""
FileOpen(1,"MyCDs.txt", OpenMode.Input)
Do While Not EOF(1) And Location = ""
CDArtist = LineInput(1)
CDTitle = LineInput(1)
CDLocation = LineInput(1)
If SearchCDArtist = CDArtist And SearchCDTitle = CDTitle Then
Location = CDLocation
End If
Loop
FileClose(1)
EndFunction
Q6 (b) (i): Python
def FindCD(SearchCDArtist, SearchCDTitle):
# CDTitle, CDArtist, CDLocation, Location : string
Location = ""
myFile = open("MyCDs.txt", 'r')
while True:
# or Location == "":
CDArtist = myFile.readline()
if CDArtist == "":
break
else:
CDTitle = myFile.readline()
CDLocation = myFile.readline()
if SearchCDArtist == CDArtist.strip()and SearchCDTitle ==
CDTitle.strip():
Location = CDLocation
myFile.close
return (Location)
© UCLES 2019
Page 10 of 11
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2019
PUBLISHED
9608/21
Q6 (b) (i): Pascal
function FindCD(SearchCDArtist, SearchCDTitle:string): string;
var
CDTitle, CDArtist, CDLocation, Location : string;
FileHandle : TextFile;
begin
Location := '';
AssignFile(FileHandle,'MyCDs.txt');
Reset (FileHandle);
while not eof(FileHandle) and (Location = '') do
begin
readln(FileHandle, CDArtist);
readln(FileHandle, CDTitle);
readln(FileHandle, CDLocation);
if (SearchCDArtist = CDArtist) and (SearchCDTitle = CDTitle)
then
end;
Location := CDLocation;
Close (FileHandle);
FindCD := Location;
end;
© UCLES 2019
Page 11 of 11