Computer Science (9608) · Oct/Nov 2018 · Mark scheme 22
Cambridge Computer Science (9608) mark scheme for paper 22, Oct/Nov 2018 — 9608/22/O/N/18, file 9608_w18_ms_22.pdf.
Text of this paper
www.dynamicpapers.com
Cambridge Assessment International Education
Cambridge International Advanced Subsidiary and Advanced Level
COMPUTER SCIENCE
9608/22
Paper 2 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 13 printed pages.
© UCLES 2018
[Turn over
9608/22
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 13
9608/22
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2018
PUBLISHED
Question
1(a)(i)
Answer
Statement
Selection
Marks
Repetition
(Iteration)
Assignment
6
3
Index ← Index + 5
3
FOR Count ← 1 TO 100
(3)
3
TempValue[Index] ←
ReadValue(SensorID)
3
IF Index < 30
3
UNTIL DayNumber > 7
3
OTHERWISE OUTPUT
"ERROR"
1 mark per correct row
Ignore any tick in assignment column for second statement
1(b)(i)
Statement
Data type
Revision ← 'B'
CHAR
MaxValue ← 13.3
REAL
ArrayFull ← TRUE
BOOLEAN
Activity ← "Design"
STRING
NumberOfEdits ← 270
INTEGER
5
1 mark per correct row
1(b)(ii)
Expression
MID(Activity, 3, 4) & "ature"
"signature"
INT(MaxValue * 2)
26
ArrayFull AND NumberOfEdits < 300
TRUE
ASC(Revision + 1)
ERROR
Activity = "Testing" OR Revision = 'A'
FALSE
1 mark per correct row
© UCLES 2018
Evaluates to
Page 3 of 13
5
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2018
PUBLISHED
9608/22
Question
Answer
2(a)(i)
FUNCTION CalcPoints(CardNum: STRING, Total: REAL)
RETURNS INTEGER
DECLARE OldPoints : INTEGER
DECLARE NewPoints : INTEGER
IF Total > 100
THEN
OldPoints ← GetPoints(CardNum)
IF OldPoints > 2000
THEN
NewPoints ← INT(Total * 1.2)
ELSE
NewPoints ← INT(Total * 1.1)
ENDIF
ELSE
NewPoints ← 0
ENDIF
RETURN NewPoints
ENDFUNCTION
1 mark for each of the following:
1
2
3
4
5
6
7
© UCLES 2018
Correct FUNCTION heading (as given) and end
Declaring local variables for OldPoints and NewPoints
IF...THEN...ELSE...ENDIF with Total > 100
«Newpoints set to zero if Total <= 100
Nested IF...THEN...ELSE...ENDIF with OldPoints > 2000
« with correct assignments of NewPoints
Return NewPoints for all cases
Page 4 of 13
Marks
7
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2018
PUBLISHED
9608/22
Question
2(a)(ii)
Answer
FUNCTION GetTotal() RETURNS REAL
Marks
5
DECLARE Valid : BOOLEAN
DECLARE Amount : REAL
Valid ← FALSE
REPEAT
OUTPUT "Enter the amount"
INPUT Amount
IF Amount > 0 AND Amount < 10000
THEN
Valid ← TRUE
ENDIF
UNTIL Valid = TRUE
RETURN Amount
ENDFUNCTION
Note that the pseudocode shown is only an example. The use of an explicit
flag and IF structure are not essential provided the functionality is provided.
1 mark for each of:
1
2
3
4
5
2(b)(i)
declaration of local variable(s) used
prompt followed by input
conditional loop
checking that input value > 0 and input value < 10000
returning the value
1 mark for name, 1 mark for description
Accept by example for description
2
Name: Run-time
Description: The program executes an illegal instruction // performs an
illegal operation that is trapped by the OS
2(b)(ii)
One specific value from within each of the following ranges:
For example:
•
•
73
145.3
(a value <= 100)
(a value > 100)
1 mark for the value, plus one for a meaningful description.
© UCLES 2018
Page 5 of 13
4
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2018
PUBLISHED
9608/22
Question
Answer
3(a)
You should be able to recognise / understand in another language:
• Declaration / assignment / sequence / selection / repetition (iteration) /
Subroutines / Parameters passed between modules / program structure
/ Input and Output
Marks
2
Any 2 marks from the list. Max 1 mark if no explanation given
3(b)
Key points:
•
•
3(c)
2
to increase the level of detail of the algorithm // break the problem into
smaller steps
until steps are easier to solve // to be directly translated into lines of
code
Key points:
•
•
•
•
4
A loop / repetition / iteration to check every element
Compare the array element with the value being searched
Exit loop / stop search when value found or end of array reached
If value is found then output the index position, otherwise output “Not
found”
Question
Answer
4(a)(i)
The identifier name of a local variable
FileData / FileLine
The identifier name of a user-defined
procedure
ScanCompleted
The identifier name of a user-defined
function
ReadFileLine / ScanFile
The number of dimensions of
ResultArray
1
The scope of FileData
Local
Marks
5
1 mark for each correct answer
4(a)(ii)
Example mark points, max 4 marks:
•
•
•
•
•
•
© UCLES 2018
If FileData is not empty, start and continue a loop // while FileData
is not empty...
Compare the Left 7 characters of FileData with SearchString
If they match, add FileData to the array / ResultArray[]
If they match, increment the array index variable
Increment FileLine
Read the next line from the file
Page 6 of 13
4
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2018
PUBLISHED
9608/22
Question
4(b)
Answer
Pseudocode solution included here for development and clarification of
mark scheme.
Programming language solutions appear at the end of this mark scheme.
Marks
8
FUNCTION ScanFile(SearchString STRING) RETURNS INTEGER
DECLARE
DECLARE
DECLARE
DECLARE
FileData : STRING
FileLine : INTEGER
NewData : STRING
Size : INTEGER
NextArrayElement ← 1
FileLine ← 1
FileData ← ReadFileLine("DataFile.txt", FileLine)
WHILE FileData <> ""
IF LEFT(FileData, 7) = SearchString
THEN
Size ← LENGTH(FileData)
NewData ← RIGHT(FileData,Size-7)
ResultArray[NextArrayElement] ← NewData
NextArrayElement ← NextArrayElement + 1
ENDIF
FileLine ← FileLine + 1
FileData ← ReadFileLine("DataFile.txt", FileLine)
ENDWHILE
CALL ScanCompleted()
RETURN FileLine
ENDFUNCTION
1 mark for each of the following:
1
2
3
4
5
6
7
8
Function heading and ending including parameters and return
statement
Local variable declarations for FileData and FileLine but NOT
declaration of NextArrayElement
initialisation of FileLine and NextArrayElement (allow 0 or 1)
WHILE ... ENDWHILE loop
Comparing SearchString with first seven characters of FileData
Use of substring function and subtraction of 7 from length
Assign NewData to array ResultArray following attempt at MP6
Increment NextArrayElement and FileLine (as above)
4(c)(i)
Through the use of: Subroutines / Functions / Procedures / Parameters /
Methods
1
4(c)(ii)
Reduces program complexity // easier to develop / test / debug // tasks may
be re-used // tasks can be allocated to different programmers/teams (with
different skills) // limited scope of local variables
1
© UCLES 2018
Page 7 of 13
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2018
PUBLISHED
9608/22
Question
4(d)
Answer
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] OF STRING
DECLARE Index: INTEGER
FOR Index ← 1 TO 100
ResultArray[Index] ← "NO DATA"
ENDFOR
1 mark for each of the following:
•
•
•
© UCLES 2018
ResultArray declaration / commented in Python
Loop for 100 elements
«assignment of string "NO DATA" to indexed array element
Page 8 of 13
Marks
3
9608/22
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2018
PUBLISHED
Question
Answer
5
PROCEDURE LineNumber(FileName: STRING,
StartNumber: INTEGER, StepNumber: INTEGER)
DECLARE
DECLARE
DECLARE
DECLARE
FileData : STRING
Count : INTEGER
Reply : CHAR
Continue : BOOLEAN
Count ← 0
Continue ← TRUE
OPENFILE FileName FOR READ
WHILE NOT EOF(FileName) AND Continue = TRUE
READFILE FileName, FileData
FileData ← NUM_TO_STRING(StartNumber) & ": " &
FileData
OUTPUT FileData
Count ← Count + 1
IF Count = 20 THEN
OUTPUT "Do you wish to continue?"
INPUT Reply
IF Reply = 'N'
THEN
Continue ← FALSE
ELSE
Count ← 0
ENDIF
ENDIF
StartNumber ← StartNumber + StepNumber
ENDWHILE
CLOSEFILE FileName
ENDPROCEDURE
© UCLES 2018
Page 9 of 13
Marks
11
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2018
PUBLISHED
9608/22
Question
5
Answer
1 mark for each of the following to max 11:
1
2
3
4
5
6
7
8
9
10
11
12
13
Procedure heading including parameters
Declare an integer variable for the count
Open file in READ mode
Initialise Count variable before loop and increment in the loop (or other
mechanism)
Loop including until EOF(FileName) (see note)
Call READFILE() in a loop
Convert StartNumber to string in a loop
Output concatenated string in a loop
Check if count = 20
Prompt and Input (inside an IF)
If user input = ‘N’ terminate loop
Add StepNumber to StartNumber
Close file
*** End of Mark Scheme – program code solutions follow ***
© UCLES 2018
Page 10 of 13
Marks
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2018
PUBLISHED
9608/22
Program Code Solutions
Q4 (b): Visual Basic
Function ScanFile(SearchString As String) As Integer
Dim
Dim
Dim
Dim
FileData As String
FileLine As Integer
NewData As String
Size As Integer
NextArrayElement = 1
FileLine = 1
FileData = ReadFileLine("DataFile.txt", FileLine)
Do While FileData <> ""
If Left(FileData, 7) = SearchString Then
Size = Len(FileData)
NewData = Right(FileData,Size-7) // NewData = Mid(FileData, 8,
Size-7)
ResultArray(NextArrayElement) = NewData
NextArrayElement = NextArrayElement + 1
End If
FileLine = FileLine + 1
FileData = ReadFileLine("DataFile.txt", FileLine)
Loop
Call ScanCompleted() ' Keyword "Call" OK but not required
Return FileLine
End Function
© UCLES 2018
Page 11 of 13
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2018
PUBLISHED
9608/22
Q4 (b): Pascal
function ScanFile(SearchString : string) : integer;
var
FileData : string;
FileLine : integer;
NewData : string;
Size : integer;
begin
NextArrayElement := 1;
FileLine := 1;
FileData
:= ReadFileLine('DataFile.txt', FileLine);
while FileData <> '' do
begin
if leftstr(FileData, 7) = SearchString then
begin
Size := Length(FileData);
NewData := rightstr(FileData,Size-7);
ResultArray[NextArrayElement] := NewData;
NextArrayElement := NextArrayElement + 1;
end;
FileLine := FileLine + 1;
FileData := ReadFileLine("DataFile.txt", FileLine);
end;
ScanCompleted(); // Keyword "Call" not valid
Return FileLine; // ScanFile := FileLine;
end;
Q4 (b): Python
def scanfile(searchstring):
# filedata : string
# fileline : integer
# newdata : string
nextarrayelement = 1
fileline = 1
filedata = readfileline("datafile.txt", fileline)
while filedata != "" :
if filedata[:7] == searchstring:
newdata = filedata[7:]
resultarray[nextarrayelement] = newdata
nextarrayelement = nextarrayelement + 1
fileline = fileline + 1
filedata = readfileline("datafile.txt", fileline)
scancompleted() # keyword "call" not valid ???
return fileline
© UCLES 2018
Page 12 of 13
9608/22
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2018
PUBLISHED
Q4 (d): Visual Basic
Dim ResultArray(99) As String
Dim Index As Integer
For Index = 0 To 99
ResultArray(Index) = "NO DATA"
Next Index
Q4 (d): Pascal
var
ResultArray : array [1..100] of string;
Index : integer;
begin
for Index := 1 to 100 do
ResultArray[Index] := 'NO DATA';
end.
Q4 (d): Python – alternative 1 of n
#ResultArray[] as STRING
Resultarray = ["NO DATA" for index in range(100)]
Q4 (d): Python – alternative 2 of n
#ResultArray[] as STRING
ResultArray = []
For Index in range(100):
ResultArray.append("NO DATA")
Q4 (d): Python – alternative 3 of n
# ResultArray[99] As String
ResultArray = ["NO DATA"]*100
© UCLES 2018
Page 13 of 13