Computer Science (9608) · Oct/Nov 2019 · Mark scheme 21
Cambridge Computer Science (9608) mark scheme for paper 21, Oct/Nov 2019 — 9608/21/O/N/19, file 9608_w19_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
October/November 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 October/November 2019 series for most
Cambridge IGCSE™, Cambridge International A and AS Level components and some Cambridge O Level
components.
This document consists of 15 printed pages.
© UCLES 2019
[Turn over
9608/21
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
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 15
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2019
PUBLISHED
9608/21
Question
1(a)(i)
Answer
One mark for each feature:
1.
2.
3.
© UCLES 2019
Marks
3
meaningful / sensible identifier names // use of Camel case for identifier
names // use of constants
blank lines / white space
comments
Page 3 of 15
9608/21
Question
1(a)(ii)
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2019
PUBLISHED
Answer
Mark as follows:
• One mark for START and END
• One mark per area outlined
At least one decision box label (YES/NO) must be
present
© UCLES 2019
Page 4 of 15
Marks
5
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2019
PUBLISHED
9608/21
Question
1(b)(i)
Answer
One mark per row
4
Example value
1(b)(ii)
Marks
Data type
"NOT TRUE"
STRING
− 4.5
REAL
NOT FALSE
BOOLEAN
132
INTEGER
One mark per row
4
Expression
Evaluates to
LEFT("Start", 3) & RIGHT("Apple", 3)
ERROR
MID("sample", 3, 5)
"24.6"
NUM_TO_STRING(12.3 * 2)
INT(STRING_TO_NUM("53.4")) + 7
© UCLES 2019
"Staple"
Page 5 of 15
60
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2019
PUBLISHED
9608/21
Question
2(a)
Answer
One mark for each feature:
1.
2.
3.
4.
2(b)
Marks
4
Module hierarchy
The parameters that are passed (between modules) // the module interface
Selection / Decisions (which modules are executed)
Iteration / Repetition
One mark for name and one mark for explanation.
2
Example:
•
•
PrettyPrint // Colour coding
Colour coding of command words / key words
•
•
Expand and collapse code blocks
Allows programmer to focus on a section of code // allows quicker navigation
of the code
•
•
Auto(matic) indentation
Allows the programmer to clearly see the different code sections / easier to
see the code structure
Accept suitable alternatives
2(c)
One mark for identification, one mark for description:
•
•
2(d)
By reference / ref
The address of / pointer to the parameter is passed to the subroutine // if the
parameter value is changed in the subroutine this changes the original value
One mark per bullet point:
•
•
© UCLES 2019
2
2
Changes made to // Updating // Editing a program / algorithm / data structure
/ software / system
...as a result of changes to requirements / specification / legislation / available
technology
Page 6 of 15
9608/21
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2019
PUBLISHED
Question
3
Answer
One mark per row:
Answer
The number of the line containing a variable being
i
t d
The range of line numbers containing a pre-condition
loop
The number of initialisation statements
The number of the line containing a logical operator
The range of line numbers containing a selection
statement
24 / 26 / 28
20 – 30
3
20
22 - 27 /
32 - 37
MID / LENGTH
The name of a built-in function
InString / Index
The name of a parameter
© UCLES 2019
Marks
Page 7 of 15
7
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2019
PUBLISHED
9608/21
Question
4(a)
Answer
One mark for process name, max 3 for structured English.
Marks
4
Process:
• Stepwise Refinement / Top-down design
Structured English:
• Check that character is between 'A' and 'Z'
• Produce unique array index for this character
• Increment this array element
4(b)
DECLARE Index : INTEGER
DECLARE Count : INTEGER
7
FOR Count ← 1 TO LENGTH(InString)
NextChar ← UCASE(MID(InString, Count, 1))
IF NextChar >= 'A' AND NextChar <= 'Z'
THEN
Index ← ASC(NextChar) – 64
Result[Index] ← Result[Index] + 1
ENDIF
ENDFOR
FOR Index ← 1 TO 26
OUTPUT "Letter " & CHR(Index + 64) & " : "
& NUM_TO_STRING(Result[Index])
ENDFOR
One mark for each of the following (max 7):
1
2
3
4
5
6
7
8
© UCLES 2019
First loop from 1 to length of InString:
Extract each character in turn in a loop
Check that character is alphabetic (must cater for lower & upper case) in a
loop
Obtain array index using ASC() - 64 in a loop
Increment element of Result array in a loop
Second loop from 1 to 26:
Attempt to OUTPUT character A to Z and corresponding count in a loop
Fully complete OUTPUT including any necessary type conversion in a loop
Page 8 of 15
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2019
PUBLISHED
9608/21
Question
5(a)
Answer
One mark for each point.
3
A valid string must contain:
•
•
•
© UCLES 2019
Marks
At least two // more than one upper case character(s)
At least five // more than four lower case character(s)
More digit characters than 'other' characters
Page 9 of 15
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2019
PUBLISHED
9608/21
Question
5(b)(i)
Answer
One mark for each area as outlined:
Index
5(b)(ii)
Marks
NextChar
5
Upper
Lower
Digit
Other
0
0
0
0
1
'J'
1
2
'i'
1
3
'm'
2
4
'+'
5
'S'
6
'm'
3
7
'i'
4
8
't'
5
9
'h'
6
10
'*'
11
'9'
1
12
'9'
2
1
2
2
One mark per bullet point:
•
•
© UCLES 2019
2
Returned value is FALSE
Digit – Other is not greater than zero // Number of Digit same as
Other
Page 10 of 15
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2019
PUBLISHED
9608/21
Question
6(a)
Answer
To retain data when the computer is shut down / turned off // after the program
ends
Marks
1
Accept equivalent answer.
6(b)
'Pseudocode' solution included here for development and clarification of mark
scheme.
Programming language example solutions appear in the Appendix.
FUNCTION SearchFileNtoZ(AccNum : STRING) RETURNS BOOLEAN
DECLARE FileData : STRING
DECLARE Found : BOOLEAN
CONSTANT SearchFile = "UserListNtoZ.txt"
Found ← FALSE
OPENFILE SearchFile FOR READ
WHILE NOT EOF(SearchFile) AND NOT Found
READFILE SearchFile, FileData
IF AccNum & '*' = LEFT(FileData, LENGTH(AccNum)+ 1)
THEN
Found ← TRUE
ENDIF
ENDWHILE
CLOSEFILE SearchFile
RETURN Found
ENDFUNCTION
One mark for each of the following:
1.
2.
3.
4.
5.
6.
7.
© UCLES 2019
Function heading and ending, (ignore parameter) and returned BOOLEAN
File OPEN UserListNtoZ.txt in READ mode and CLOSE
Conditional loop repeating until EOF() or 'Found'
Read a line from the file in a loop
Compare the correct number of characters with AccNum in a loop
Set termination logic if found in a loop
Return Boolean value
Page 11 of 15
7
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2019
PUBLISHED
9608/21
Question
6(c)
Answer
PROCEDURE FindDuplicates()
DECLARE
DECLARE
DECLARE
DECLARE
Index : INTEGER
FileData : STRING
Continue : BOOLEAN
AccNum : STRING
Index ← 1 // assuming array is [1:100]
Continue ← TRUE
OPENFILE "UserListAtoM.txt" FOR READ
WHILE NOT EOF("UserListAtoM.txt") AND Continue = TRUE
READFILE "UserListAtoM.txt", FileData
IF MID(FileData, 7, 1) = '*' // six character reference
THEN
AccNum ← LEFT(FileData, 6)
ELSE
AccNum ← LEFT(FileData, 9)
ENDIF
IF SearchFileNtoZ(AccNum) = TRUE
THEN
IF Index = 101 // is the array already full?
THEN
OUTPUT "Error – Array Full"
Continue ← FALSE
ELSE
Duplicates[Index] ← AccNum
Index ← Index + 1
ENDIF
ENDIF
ENDWHILE
CLOSEFILE "UserListAtoM.txt"
ENDPROCEDURE
One mark for each of the following (max 8):
1. Declaration and Initialisation of Index and used to index array
Duplicates
2. OPEN file UserListAtoM.txt in READ mode and CLOSE
3. Pre-Condition loop to go through the file until EOF() and early termination
if array full
4. Read line from file and extract account number (AccNum) in a loop
5. Call SearchFileNtoZ (with AccNum) following an attempt at MP4 in a
loop
6. Check if return value is TRUE and if so: in a loop
7.
store AccNum in correct array element
8. increment array index following an attempt at MP7
9. If array overflow OUTPUT error message
© UCLES 2019
Page 12 of 15
Marks
8
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2019
PUBLISHED
9608/21
Question
Answer
6(d)(i)
PROCEDURE ClearArray(BYREF ThisArray : ARRAY,
NumElements : INTEGER, InitVal : STRING)
Marks
3
DECLARE Index : INTEGER
FOR Index ← 1 TO NumElements
ThisArray[Index] ← InitVal
ENDFOR
ENDPROCEDURE
Mark as follows:
• Procedure header
• Loop
• Assignment within loop
6(d)(ii)
'Pseudocode' solution included here for development and clarification of mark
scheme.
Programming language example solutions appear in the Appendix.
CALL ClearArray(Duplicates, 100, "Empty")
Mark as follows:
•
•
© UCLES 2019
Procedure call
Parameter list (in brackets)
Page 13 of 15
2
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2019
PUBLISHED
9608/21
Program Code Example Solutions
Question 6(b): Visual Basic
Function SearchFileNtoZ(ByVal SearchString As String) As Boolean
Dim FileData As String
Dim Found As Boolean
Found = FALSE
FileOpen(1, "UserListNtoZ.txt", OpenMode.Input)
While Not EOF(1) And Not Found
Filedata = LineInput(1)
If SearchString & '*' = Left(FileData, Len(SearchString)+1) Then
Found = TRUE
End If
End While
FileClose(1)
Return Found
End Function
Question 6(b): Pascal
function SearchFileNtoZ (SearchString : string): boolean;
var
FileData : string;
Found : boolean;
MyFile : text;
begin
Found := FALSE;
assign(MyFile, "UserListNtoZ.txt");
reset (Myfile);
then
while Not EOF(MyFile) And Not Found do
begin
readLn(MyFile, FileData);
if SearchString + '*' = LeftStr(FileData, length(SearchString)+1)
Found := TRUE;
end;
close(MyFile);
result := Found; // SearchFileB := Found;
end;
© UCLES 2019
Page 14 of 15
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2019
PUBLISHED
9608/21
Question 6(b): Python
def SearchFileNtoZ(SearchString):
## FileData : String
## Found : Boolean
## MyFile : Text
Found = False
MyFile = open("UserListNtoZ.txt", 'r')
FileData = MyFile.readline()
while Filedata != "" and not Found :
if SearchString + '*' == FileData[0: len(SearchString)+1]:
Found = True
FileData = MyFile.readline()
MyFile.close
return(Found)
Question 6(d)(ii): Visual Basic
Call ClearArray(Duplicates, 100, "Empty") 'Call optional
Question 6(d)(ii): Pascal
ClearArray(Duplicates, 100, 'Empty');
Question 6(d)(ii): Python
ClearArray(Duplicates, 100, "Empty")
© UCLES 2019
Page 15 of 15