Computer Science (9608) · May/June 2018 · Mark scheme 23
Cambridge Computer Science (9608) mark scheme for paper 23, May/June 2018 — 9608/23/M/J/18, file 9608_s18_ms_23.pdf.
Text of this paper
www.dynamicpapers.com
Cambridge Assessment International Education
Cambridge International Advanced Subsidiary and Advanced Level
COMPUTER SCIENCE
9608/23
Paper 2 Written Paper
May/June 2018
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 2018 series for most
Cambridge IGCSE™, Cambridge International A and AS Level and Cambridge Pre-U components, and
some Cambridge O Level components.
IGCSE™ is a registered trademark.
This document consists of 13 printed pages.
© UCLES 2018
[Turn over
9608/23
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
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 2018
Page 2 of 13
9608/23
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED
Question
Answer
Marks
1(a)
4
Description of data item
The temperature inside the house
The temperature outside the house
Suitable identifier name
InsideTemperature
OutsideTemperature
The wind speed
WindSpeed
Whether it was raining or not
WasRaining
The above are examples only.
Names must be meaningful and unambiguous
Items 1 and 2 must have suitable prefix/suffix (i.e. not just ‘temperature’)
Reject single letter names
1(b)(i)
5
Expression
Evaluates to
MID(MyName, 4, 4) & "ol"
"phenol"
QualityConfirmed AND (Factor >= 6.5)
20 + ASC(Quality)
88
QualityConfirmed + 3
ERROR
MOD(Factor * 2, 9)
4
1(b)(ii)
5
Variable
Data type
QualityConfirmed
BOOLEAN
DayNumber
INTEGER
Factor
REAL
Quality
CHAR
MyName
STRING
One mark per answer
© UCLES 2018
TRUE
Page 3 of 13
9608/23
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED
Question
2(a)
Answer
Marks
Comments:
Explain the functionality of the code // Easier for other people to
understand // Easier to maintain / debug / modify
2
Indentation:
Easier to identify structure / blocks // identify blocks of code
2(b)
9
Feature
A line number containing an example of an
integer assignment statement
8, 9, 10,12, 17,
34, 45
A line number containing the start of a
selection structure
14, 19, 23
A line number containing the end of a
selection structure
28, 29, 30
The upper bound of the Mark array
100
The number of dimensions of the Mark array
1
The name for the type of loop structure used
‘post condition’
A line number containing an unnecessary
assignment statement
10
The number of times that OUTPUT is called
100
The number of local variables
2(c)(i)
Answer
4
Either:
• Mistake: function header specifies return of an INTEGER but line 37
returns a STRING // pseudocode returns Grade but should have
returned DGradeCount
• Correction: RETURN DGradeCount (as per code pseudocode
comment)
Or:
• Mistake: Statement on line 32 uses ‘&’ operator which concatenates
STRINGs, but variable n is an INTEGER
• Correction: Convert n to a STRING before concatenating
© UCLES 2018
Page 4 of 13
2
Cambridg
ge Internatio
onal AS/A Level
L www.dynamicpapers.com
– Mark Scheme
Ma
ay/June 201
18
P
PUBLISHED
D
9608/23
9
Question
2(c)(ii)
Answerr
CASE OF
F ThisMar
rk
> 74: Grade ← "Distinc
ction"
ount ← DG
GradeCoun
nt + 1
DGradeCo
60 TO 74: Grade ← "Merit"
40 TO 59: Grade ← "Pass"
HERWISE Grade ← "Fail"
OTH
ENDCASE
E
Marks
4
One marrk for each of:
o
1
2
3
4
CASE
E OF This
sMark ...
. ENDCASE
E
Thre
ee grade ran
nges with co
orrespondin
ng assignment of Grad
de
DGra
adeCount increment w
within CASE
E clause
OTHE
ERWISE / fo
ourth grade range with correct ass
signment off Grade
Question
3(a)
Answerr
Paramete
ers
Marks
1
Accept arguments
3(b)
4
Mark as follows:
f
•
•
© UCLES 2018
One mark for all four modu
ules
ach set of in
nterface parameters
One mark for ea
Page 5 of 13
Cambridg
ge Internatio
onal AS/A Level
L www.dynamicpapers.com
– Mark Scheme
Ma
ay/June 201
18
P
PUBLISHED
D
9608/23
9
Question
Answerr
4
9
This is on
ne possible solution – sselection sttructure may differ
One marrk for:
1
2
3
4
5
6
7
8
9
STAR
RT and END
D // STOP
P
Initia
alisation of an
a Index vvariable and
d initialisatio
on of a Coun
e
nt variable
Deciision box / boxes
b
to che
eck temperrature within
n acceptablee range
Corrrect increme
ent of Coun t variable
Deciision box co
omparing In
ndex to 100
Corrrect increme
ent of Inde x
Deciision box co
omparing Co
ount > 20
Assig
gning both TRUE and F
FALSE
Retu
urning the Boolean
B
valu
ue
For soluttions where Boolean va
ariable not used:
u
8
9
© UCLES 2018
Marks
Retu
urn TRUE
R
Return
FALS
SE
Page 6 of 13
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED
9608/23
Question
Answer
Marks
5(a)(i)
1
1
5(a)(ii)
Information is saved after the program ends // after the computer is switched
off
1
5(b)
Two from these examples:
•
•
•
© UCLES 2018
Max 2
Indentation
Colour-coding of keywords /comments
Expansion / collapsing of complex data structures
Page 7 of 13
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED
9608/23
Question
5(c)
Answer
‘Pseudocode’ solution included here for development and clarification of
mark scheme.
Programming language solutions appear in the Appendix.
FUNCTION GetAverageScore(MembershipNumber : STRING)
RETURNS INTEGER
DECLARE FileData, FileMembershipNumber : STRING
DECLARE NumberOfScores, TotalScore, AverageScore :
INTEGER
OPENFILE "ScoreDetails.txt" FOR READ
NumberOfScores ← 0
TotalScore ← 0
WHILE NOT EOF("ScoreDetails.txt")
READFILE("ScoreDetails.txt", FileData)
FileMembershipNumber ← LEFT(FileData, 4)
IF FileMembershipNumber = MembershipNumber
THEN
NumberOfScores ← NumberOfScores + 1
TotalScore ← TotalScore +
INT(RIGHT(FileData, 2))
ENDIF
ENDWHILE
AverageScore ← INT(TotalScore / NumberOfScores)
CLOSEFILE("ScoreDetails.txt")
RETURN(AverageScore)
ENDFUNCTION
1 mark for each of the following:
1
2
3
4
5
6
7
8
9
10
11
12
13
© UCLES 2018
Function heading and ending including Input and return parameter
Declare variables to store NumberOfScores and TotalScore as
INTEGERs (commented in Python) (variable names may be different)
Initialisation of NumberOfScores and TotalScore to 0
Open file in READ mode
Loop until EOF()
Read a line from the file in a loop
Use of substring function to extract at least one data item
Compare the membership number
Convert score to an integer
Increment NumberOfScores and sum TotalScore
Calculate the average outside the loop
Close the file
Return the parameter
Page 8 of 13
Marks
Max 10
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED
9608/23
Question
Answer
Marks
6(a)
Subscript / index
1
6(b)
FUNCTION Clip(MaxVal : INTEGER) RETURNS BOOLEAN
DECLARE i : INTEGER
DECLARE j : INTEGER
DECLARE ClipFlag : BOOLEAN
9
ClipFlag ← FALSE
FOR i ← 1 TO 8
FOR j ← 1 TO 8
IF Picture[i, j] > MaxVal
THEN
Picture[i, j] ← MaxVal
ClipFlag ← TRUE
ENDIF
ENDFOR
ENDFOR
RETURN ClipFlag
ENDFUNCTION
1 mark for each of the following:
1
2
3
4
5
6
7
8
9
© UCLES 2018
Correct Function heading (must have MaxVal and return a BOOLEAN)
and ending
Declare and initialise local variable for return BOOLEAN to FALSE / other
mechanism to record pixel being clipped
Declare local variables for loop counters
Nested loops with correct number of iterations
Accessing correct element from Picture array
Comparing element with MaxVal
Changing value of element if necessary
Setting flag to TRUE / other mechanism if element is changed
Returning BOOLEAN after loop (following conversion if other
mechanism used)
Page 9 of 13
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED
9608/23
Question
7
Answer
‘Pseudocode’ solution included here for development and clarification of
mark scheme.
Programming language solutions appear in the Appendix.
FUNCTION IsFactor(Num1: INTEGER, Num2: INTEGER)
RETURNS BOOLEAN
IF Num2 <> 0
THEN
IF MOD(Num1, Num2) = 0
THEN
RETURN TRUE
ENDIF
ENDIF
RETURN FALSE
ENDFUNCTION
1 mark for each of the following:
1
2
3
4
5
6
Correct Function heading (including parameters) and ending
Check that Num2 is not zero
Mechanism to ensure no call to MOD (or equivalent) if Num2 is zero
Use of MOD function or alternative
Check value of remainder
Return Boolean value
*** End of Mark Scheme – program code example solutions follow ***
© UCLES 2018
Page 10 of 13
Marks
6
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED
9608/23
Appendix
Program Code Example Solutions
Q5(c): Visual Basic
Function GetAverageScore(ByVal MembershipNumber As String) As Integer
Dim
Dim
Dim
Dim
Dim
Dim
FileData As String
FileMembershipNumber As String
NumberOfScores As Integer
TotalScore As Integer
AverageScore As Integer
ObjReader As IO.StreamReader
ObjReader = New IO.StreamReader("ScoreDetails.txt")
NumberOfScores = 0
TotalScore = 0
Do While ObjReader.Peek <> -1
FileData = ObjReader.ReadLine()
FileMembershipNumber = LEFT(FileData, 4)
If FileMembershipNumber = MembershipNumber Then
NumberOfScores = NumberOfScores + 1
TotalScore = TotalScore + INT(RIGHT(FileData, 2))
End If
Loop
AverageScore = INT(TotalScore / NumberOfScores)
ObjReader.Close()
Return (AverageScore)
End Function
Q5(c): Pascal
function GetAverageScore(MembershipNumber : string):integer;
var
FileData, FileMembershipNumber: string;
NumberOfScores, TotalScore, AverageScore : integer;
ScoreFile : textFile;
begin
NumberOfScores := 0;
TotalScore := 0;
assignFile(ScoreFile, ‘ScoreDetails.txt’);
reset(ScoreFile);
while not eof(ScoreFile) do
begin
readln(ScoreFile, FileData);
FileMembershipNumber := copy(FileData, 1, 4);
if FileMembershipNumber = MembershipNumber then
begin
NumberOfScores := NumberOfScores + 1
TotalScore := TotalScore + StrToInt(RightStr(FileData, 2));
end;
end;
© UCLES 2018
Page 11 of 13
9608/23
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED
AverageScore := StrToInt(TotalScore / NumberOfScores);
GetAverageScore := AverageScore;
CloseFile (ScoreFile);
end;
Q5(c): Python
#
#
#
#
#
FileData AS STRING
FileMembershipNumber AS STRING
NumberOfScores AS INTEGER
TotalScore AS INTEGER
AverageScore AS INTEGER
def GetAverageScore(MembershipNumber):
FileHandle = open("ScoreDetails.txt", "r")
NumberOfScores = 0
TotalScore = 0
FileData = FileHandle.readline()
while len(FileData) > 0:
FileMembershipNumber = FileData[0:4]
if FileMembershipNumber == MembershipNumber:
NumberOfScores = NumberOfScores + 1
TotalScore = TotalScore + int(FileData[-2])
FileData = FileHandle.readline()
AverageScore = int(TotalScore / NumberOfScores)
Return (AverageScore)
FileHandle.close()
© UCLES 2018
Page 12 of 13
9608/23
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
May/June 2018
PUBLISHED
Q7: Visual Basic
Function IsFactor(Num1 As Integer, Num2 As Integer) As Boolean
If Num2 <> 0 Then
If Num1 Mod Num2 = 0 Then
Return True
End If
End if
Return False
End Function
Q7: Pascal
function IsFactor(Num1,Num2 : integer) : boolean;
begin
if Num2 <> 0 then
begin
if Num1 MOD Num2 = 0 then
Return True;
end;
Return False;
end;
Q7: Python
def IsFactor (Num1, Num2):
if Num2 != 0:
if Num1 % Num2 == 0:
Return True
Return False
© UCLES 2018
Page 13 of 13