Computer Science (9608) · Oct/Nov 2018 · Mark scheme 21
Cambridge Computer Science (9608) mark scheme for paper 21, Oct/Nov 2018 — 9608/21/O/N/18, file 9608_w18_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 1 Written Paper
October/November 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 October/November 2018 series for most
Cambridge IGCSE™, Cambridge International A and AS Level components and some Cambridge O Level
components.
This document consists of 12 printed pages.
© UCLES 2018
[Turn over
9608/21
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
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 12
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2018
PUBLISHED
9608/21
Question
Answer
1(a)(i)
Statement
Marks
Selection
Repetition
(Iteration)
Assignment
6
9
WHILE Count < 20
Count ← Count + 1
9
9
If MyGrade <> 'C' THEN
Mark[Count] ←
GetMark(StudentID)
9
9
ELSE OUTPUT "Fail"
9
ENDFOR
One mark for each row
1(b)(i)
1(b)(ii)
© UCLES 2018
Statement
Data type
MyAverage ← 13.5
REAL
ProjectCompleted ← TRUE
BOOLEAN
Subject ← "Home Economics"
STRING
MyMark ← 270
INTEGER
MyGrade ← 'B'
CHAR
Expression
Evaluates to
"Air-" & MID(Subject, 7, 3)
"Air-con"
INT(MyAverage / 2)
6
ProjectCompleted AND MyMark > 270
FALSE
ProjectCompleted OR MyMark > 260
TRUE
ASC(MyGrade / 3)
ERROR
Page 3 of 12
5
5
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2018
PUBLISHED
9608/21
Question
2(a)
Answer
FUNCTION GetDiscountRate(CardNum : STRING) RETURNS REAL
DECLARE DRate : REAL
DECLARE Points : INTEGER
Marks
8
DRate ← 0
Points ← GetPoints(CardNum)
IF Points > 199
THEN
DRate ← 0.2
ELSE
IF Points > 99
THEN
DRate ← 0.1
ENDIF
ENDIF
IF Today() = 3
THEN
DRate ← DRate * 1.2
ENDIF
RETURN DRate
ENDFUNCTION
1 mark for each of the following:
1
2
3
4
5
6
7
8
Correct FUNCTION heading (as given) and end
Declaring local variables for DRate and Points
Initialisation of DRate to zero and Points ← GetPoints(CardNum)
IF
THEN ...(ELSE) … ENDIF with Points > 199
(Nested) IF ... THEN … ENDIF with Points > 99
correct assignments of DRate to 0.2 and 0.1
Checking Today() = 3 and increasing DRate by 20%
Return parameter // GetDiscountRate ← DRate
Mark points 7 and 8 must not be nested
2(b)(i)
Name: Syntax
Description: Rules of programming language have not been followed
2
Name: Logic
Description: Where the program does not behave as expected / does not give the
expected result / an error in the logic of the algorithm
1mark for name + 1 mark for corresponding description
2(b)(ii)
Name: Stub testing
2
Description: A function could be written for GetPoints() that simply returns a
test value or outputs a message (i.e. doesn't do the CardNum lookup)
© UCLES 2018
Page 4 of 12
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2018
PUBLISHED
9608/21
Question
2(c)(i)
Answer
1 mark for any of the following two values:
Marks
1
0.1
0.2
1.2
99
199
3
2(c)(ii)
Example:
2
CONSTANT MinDiscount = 0.1
1 mark for each of the following:
•
•
2(c)(iii)
meaningful identifier name and corresponding value
correct syntax
1 mark for:
2
•
•
The value cannot accidentally get changed // be different in two places
A change to the value requires changing in one place only / don’t have to
repeatedly write out the same value throughout the program
2(c)(iv)
Tried and tested // pre compiled (contains no syntax errors)
1
2(c)(v)
1 mark for feature (Name) and 1 mark for corresponding description (explanation)
2
Example:
Name: Meaningful variable names
Explanation: To reduce the risk of referring to the wrong variable / make the code
easier to understand
Name: Indentation
Explanation: To see where loops / selection start / end // indicate program structure
Name: Variable type-checking as part of module interface
Explanation: Reduces the risk of using an incorrect parameter
Name: Pretty-Printing
Explanation: Highlights the error / auto-complete / type checking
Name: / Dynamic Syntax Checking
Explanation: Highlights the error as code is typed in
© UCLES 2018
Page 5 of 12
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2018
PUBLISHED
9608/21
Question
Answer
Marks
3(a)
Code has to be in machine code (or equivalent) to be executed
1
3(b)
1 mark for the name (what you do) and one for description (how)
4
For example:
Method:
• Dry run the code // use of white box testing // trace tables
• Trace the contents of variables // trace all possible routes through the program
Method:
• Breakpoints
• Run the code to a set point to find error
Method:
• Variable watch
• Check the contents of variables at specific points in the program
Method:
• Stepping
• Execute the code line by line
Method:
• Include OUTPUT statements in the code
• to display the value of variables as the code was running
3(c)
Statement
White-box
9
The student does not need to know the structure of
the code.
The student chooses data to test every possible path
through the code.
9
The student chooses normal, boundary and
erroneous data.
9
The student chooses data to test that the program
meets the specification.
1 mark per row
© UCLES 2018
Page 6 of 12
Black-box
(9)
9
4
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2018
PUBLISHED
9608/21
Question
Answer
4(a)(i)
4(a)(ii)
The identifier name of a global integer referenced
NumElements
The identifier name of a user-defined procedure
SaveToFile
The line number of an unnecessary statement
16
The scope of ArrayString
Local
1 mark for each mark point:
•
•
•
•
4(b)
Marks
4
Loop / repeat / iterate through array ResultArray one element at a time
extract a string from row / column 1 of the array
compare the string with SearchString
if they match, call SaveToFile() and increment NumberFound
Pseudocode solution included here for development and clarification of mark
scheme.
Programming language solutions appear at the end of this mark scheme.
FUNCTION ScanArray(SearchString : STRING) RETURNS INTEGER
DECLARE ArrayIndex : INTEGER
DECLARE ArrayString : STRING
DECLARE NumberFound : INTEGER
NumberFound ← 0
FOR ArrayIndex ← 1 TO NumElements
ArrayString ← ResultArray[ArrayIndex, 1]
IF TO_UPPER(ArrayString) = TO_UPPER(SearchString)
THEN
CALL SaveToFile(ArrayString)
NumberFound ← NumberFound + 1
ENDIF
ENDFOR
RETURN NumberFound
ENDFUNCTION
1 mark for each of the following:
1
2
3
4
5
6
© UCLES 2018
4
Function header and end including parameter and return
Declaration of two local variables as above but NOT NumElements
FOR … ENDFOR loop with range as given
Referencing each element from the array
Converting both strings to uppercase / lowercase
If strings are equal then Call SaveToFile()and increment NumberFound
Page 7 of 12
6
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2018
PUBLISHED
9608/21
Question
4(c)
Answer
1 mark for name; 1 mark for each advantage (max 2)
Marks
3
Name:
Stepwise refinement // Top-down design // Modularisation // Decomposition
Advantage:
• Makes the problem / task / algorithm easier to understand // reduce program
complexity
• Smaller modules easier to develop / test / debug
• Programmers can work on different modules // different expertise
4(d)
Pseudocode solution included here for development and clarification of mark
scheme.
Programming language solutions appear at the end of this mark scheme.
DECLARE ResultArray : ARRAY [1:100, 1:2] OF STRING
DECLARE i, j : INTEGER
FOR i ← 1 to 100
FOR j ← 1 to 2
ResultArray[i, j] ← '*'
ENDFOR
ENDFOR
One mark for:
• ResultArray declaration / commented in Python
• assigning to all elements
• assignment of ‘*’
© UCLES 2018
Page 8 of 12
3
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2018
PUBLISHED
9608/21
Question
5
Answer
FUNCTION SaveStatus() RETURNS BOOLEAN
DECLARE
DECLARE
DECLARE
DECLARE
DECLARE
DECLARE
Time : STRING
Fuel : STRING
Distance : STRING
FileData : STRING
Tries : INTEGER
ReturnFlag : BOOLEAN
Tries ← 1
ReturnFlag ← TRUE
Distance ← GetDistance()
Fuel ← GetFuel()
Time ← GetTime()
WHILE Time = NULL AND Tries < 3
Time ← GetTime()
Tries ← Tries + 1
ENDWHILE
IF Time = NULL
THEN
ReturnFlag ← FALSE
ELSE
FileData ← Time & ',' & Fuel & ',' & Distance
OPENFILE "CarStatus.txt" FOR APPEND
WRITEFILE "CarStatus.txt", FileData
CLOSEFILE "CarStatus.txt"
ENDIF
RETURN ReturnFlag
ENDFUNCTION
1 mark for each of the following:
1
2
3
4
5
6
7
8
9
10
© UCLES 2018
Function heading as shown
Declare Time local variable as STRING
Calls GetDistance()and GetFuel() once
Loop (up to three times or) until Time <> NULL
Call GetTime()in a loop
Return FALSE if 3 NULLs
Open file in APPEND mode
Forming the text string with comma separators and write to the file
OPEN
WRITE
CLOSE as three lines not separated by loop
Return TRUE
Page 9 of 12
Marks
10
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2018
PUBLISHED
9608/21
Program Code Solutions
Q4 (b): Visual Basic
Function ScanArray(SearchString As String) As Integer
Dim ArrayIndex As Integer
Dim ArrayString As String
Dim NumberFound As Integer
NumberFound = 0
For ArrayIndex = 1 To NumElements
ArrayString = ResultArray(ArrayIndex, 1)
If UCase(ArrayString) = UCase(SearchString) Then
Call SaveToFile(ArrayString)
NumberFound = NumberFound + 1
End If
Next ArrayIndex
Return NumberFound
End Function
Q4 (b): Pascal
function ScanArray(SearchString : String) : Integer;
var
ArrayIndex : Integer;
ArrayString : String;
NumberFound : Integer;
begin
NumberFound := 0;
For ArrayIndex := 1 To NumElements do
begin
ArrayString := ResultArray[ArrayIndex, 1];
If ToUpper(ArrayString) = ToUpper(SearchString) then
begin
SaveToFile(ArrayString); // Keyword "Call" not valid
NumberFound := NumberFound + 1;
end;
end;
Result := NumberFound; // ScanArray := NumberFound
end.
© UCLES 2018
Page 10 of 12
9608/21
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2018
PUBLISHED
Q4 (b): Python
def ScanArray(SearchString):
# ArrayIndex : integer
# ArrayString : string
# NumberFound : integer
NumberFound = 0
for ArrayIndex in range(NumElements): # 0 to NumElements-1
ArrayString = ResultArray[ArrayIndex][0]
if ArrayString.upper == SearchString.upper:
SaveToFile(ArrayString) # Keyword "Call" not valid
NumberFound = NumberFound + 1
return NumberFound # ScanArray := NumberFound
© UCLES 2018
Page 11 of 12
9608/21
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2018
PUBLISHED
Q4 (d): Visual Basic
Dim ResultArray(100, 2) As String
Dim I, j As Integer
For i = 1 to 100
For j = 1 to 2
ResultArray(i, j) = '*'
Next j
Next i
Q4 (d): Pascal
var
ResultArray : array[1..100, 1..2] of string;
i, j : integer;
begin
For i := 1 to 100 do
For j := 1 to 2 do
begin
ResultArray[i, j] := '*';
end;
end.
Q4 (d): Python
# ResultArray[1..100, 1..2] : String
ResultArray = [[0] * 2 for i in range(100)]
for i in range(100):
for j in range(2):
ResultArray[i][j] = '*'
Q4 (d): Python – alternative 1 of n
# ResultArray[1..100, 1..2] : String
ResultArray = [['*'] * 2 for i in range(100)]
Q4 (d): Python – alternative 2 of n
# ResultArray[1..100, 1..2] : String
ResultArray = [['*'] * 2] * 100
© UCLES 2018
Page 12 of 12