Computer Science (9608) · Oct/Nov 2018 · Mark scheme 41
Cambridge Computer Science (9608) mark scheme for paper 41, Oct/Nov 2018 — 9608/41/O/N/18, file 9608_w18_ms_41.pdf.
Text of this paper
www.dynamicpapers.com
Cambridge Assessment International Education
Cambridge International Advanced Subsidiary and Advanced Level
COMPUTER SCIENCE
9608/41
Paper 4 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 18 printed pages.
© UCLES 2018
[Turn over
9608/41
Cambridge International AS/A Level – Mark Scheme
PUBLISHED
Generic Marking Principles
October/November 2018
www.dynamicpapers.com
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.
© UCLES 2018
Page 2 of 18
9608/41
Cambridge International AS/A Level – Mark Scheme
PUBLISHED
October/November 2018
www.dynamicpapers.com
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 3 of 18
9608/41
Cambridge International AS/A Level – Mark Scheme
PUBLISHED
Question
1(a)(i)
Answer
1 mark for each correct statement:
•
•
1(a)(ii)
Marks
2
bird(lays_egg).
bird(has_wings).
1 mark for each correct line:
•
•
1(b)(i)
October/November 2018
www.dynamicpapers.com
2
feature(eagle, lays_eggs).
feature(eagle, has_wings).
1 mark for each animal:
2
tuna, crab
1(b)(ii)
1 mark per bullet point:
•
•
2
feature()
tuna, C
feature(tuna, C)
1(c)
1 mark per bullet point to max 3:
•
•
•
3
feature(X,Y) AND bird(Y) // feature(X, has_wings)
AND
feature(X,Z) AND bird(Z) // feature(X, lays_eggs)
(feature(X, Y) AND bird(Y)) AND (feature(X, Z) AND bird(Z))
1(d)(i)
A programming style/classification // characteristics/features that programming language has/uses
1
1(d)(ii)
1 mark for each:
2
•
•
© UCLES 2018
Low-level
Imperative // Procedural
Page 4 of 18
9608/41
Cambridge International AS/A Level – Mark Scheme
PUBLISHED
Question
2(a)
Answer
1 mark per bullet point to max 4:
•
•
•
•
For example:
© UCLES 2018
Marks
4
declaration of type Book
Title, Author and ISBN as String
Fiction as Boolean
LastRead as Date
TYPE Book
DECLARE
DECLARE
DECLARE
DECLARE
DECLARE
ENDTYPE
October/November 2018
www.dynamicpapers.com
Title : String
Author : String
ISBN : String
Fiction : Boolean
LastRead : Date
Page 5 of 18
9608/41
Cambridge International AS/A Level – Mark Scheme
PUBLISHED
Question
2(b)
Answer
1 mark per bullet point to max 4:
•
•
•
•
•
Marks
4
Function header
« taking ISBN as parameter
Converting ISBN to integer
Calculating Hash (ISBN mod 2000 + 1)
Returning the calculated Hash
Examples:
Python:
def Hash(ISBN):
ISBNint = int(ISBN)
Hash = (ISBNint % 2000) + 1
VB.NET:
Function Hash (ISBN As String) As Integer
ISBNint = convert.toInt32(ISBN)
Hash = (ISBNint MOD 2000) + 1
End Function
Pascal:
function Hash(ISBN : String) : Integer
begin
ISBNint = StrToInt(ISBN)
Hash = (ISBNint MOD 2000) + 1
end;
© UCLES 2018
October/November 2018
www.dynamicpapers.com
Page 6 of 18
9608/41
Cambridge International AS/A Level – Mark Scheme
PUBLISHED
Question
2(c)
Answer
1 mark per bullet point to max 8:
•
•
•
•
•
•
•
•
•
•
© UCLES 2018
October/November 2018
www.dynamicpapers.com
Marks
8
Procedure FindBook declaration and prompt and input ISBN
Validate data input has 13 characters
« and are all numeric
..loop until valid
Call Hash() with input data and store return data
Open MyBooks.dat for reading as random file and close
Finding the record using return value Hash()
Get the data for the record
«store in variable of type Book
«output all the data for the record
Page 7 of 18
9608/41
Cambridge International AS/A Level – Mark Scheme
PUBLISHED
Question
2(c)
Answer
Example:
PROCEDURE FindBook()
DECLARE BookInfo : Book
REPEAT
ISBN ← input("Enter the ISBN number")
Valid ← TRUE
Size ← LENGTH(ISBN)
IF size <> 13
THEN
Valid ← FALSE
ELSE
FOR i ← 1 to 13
IF NOT( MID(ISBN,i,1) >= '0' AND MID(ISBN,i,1)<= '9' )
THEN
Valid ← FALSE
ENDIF
ENDFOR
ENDIF
UNTIL Valid
Filename ← "myBooks.dat"
OPENFILE Filename FOR RANDOM
RecordLocation ← Hash(ISBN)
SEEK FileName, RecordLocation
GETRECORD Filename, BookInfo
CLOSEFILE Filename
OUTPUT (BookInfo.Title & " " & BookInfo.Author & " " &
BookInfo.ISBN & " " & BookInfo.Fiction & " " &
BookInfo.LastRead)
ENDPROCEDURE
© UCLES 2018
Page 8 of 18
October/November 2018
www.dynamicpapers.com
Marks
9608/41
Cambridge International AS/A Level – Mark Scheme
PUBLISHED
Question
3(a)
Answer
•
October/November 2018
www.dynamicpapers.com
Marks
1
LIFO / last in first out
3(b)(i)
Points to the next free space on the stack
1
3(b)(ii)
1 mark per bullet to max 3
2
•
•
Correct stack contents
StackPointer = 4
StackPointer
StackContents
4
0
"Screw 1"
1
"Screw 2"
2
"Back case"
3
"Light 1"
4
5
6
7
© UCLES 2018
Page 9 of 18
9608/41
Cambridge International AS/A Level – Mark Scheme
PUBLISHED
Question
3(c)(i)
Answer
1 mark for each correct statement:
October/November 2018
www.dynamicpapers.com
Marks
5
PROCEDURE POP
IF StackPointer = 0
THEN
OUTPUT ("The stack is empty")
ELSE
StackPointer ← StackPointer - 1
OUTPUT Parts[StackPointer]
Parts(StackPointer) ← "*"
ENDIF
ENDPROCEDURE
3(c)(ii)
1 mark for each completed statement:
4
PROCEDURE PUSH (BYVALUE Value : String)
IF StackPointer > 19
THEN
OUTPUT "Stack full"
ELSE
Parts[StackPointer] ← Value
StackPointer ← StackPointer + 1
ENDIF
ENDPROCEDURE
© UCLES 2018
Page 10 of 18
9608/41
Cambridge International AS/A Level – Mark Scheme
PUBLISHED
Question
October/November 2018
www.dynamicpapers.com
Answer
Marks
4(a)(i)
A function/subroutine defined in terms of itself // a function/subroutine that calls itself
1
4(a)(ii)
06
1
1 mark for each bullet point:
6
4(b)
•
•
–60 as final return value
3*2*1*–10
1 mark for each row in table
Call Number
4(c)(i)
Number = 0 ?
Return value
1
Calculate(3)
False
3*Calculate(2)
2
Calculate(2)
False
2*Calculate(1)
3
Calculate(1)
False
1*Calculate(0)
4
Calculate(0)
TRUE
–10
1 mark per bullet point:
•
•
© UCLES 2018
Function call
2
Each time it calls itself the variables are put onto the stack // The function call itself too many times
« it runs out of stack space // stack overflow
Page 11 of 18
9608/41
Cambridge International AS/A Level – Mark Scheme
PUBLISHED
Question
4(c)(ii)
October/November 2018
www.dynamicpapers.com
Answer
1 mark per bullet point to max 5:
•
•
•
•
•
Marks
5
Function header with parameter and Returning calculated value
Loop parameter times (up to number, or down from number)«
«Multiplying by loop counter
Multiplying by –10
Dealing with starting value correctly
For example:
FUNCTION Calculate(Number : INTEGER) RETURNS INTEGER
DECLARE Count : INTEGER
DECLARE Value : INTEGER
Value ← −10
FOR Count ← 1 to Number
Value ← Value * Count
ENDFOR
RETURN Value
ENDFUNCTION
Question
5(a)
Answer
1 mark per bullet point to max 2:
•
•
•
© UCLES 2018
Marks
2
To restrict direct access to the property to the class // keep the properties secure // So the data can only be accessed
by its methods // makes the program more robust
To make the program easier to debug
To ensure data going in is valid // to stop invalid changes // stop accidental changes
Page 12 of 18
9608/41
Cambridge International AS/A Level – Mark Scheme
PUBLISHED
Question
5(b)
Answer
1 mark per bullet point:
•
•
•
•
•
© UCLES 2018
October/November 2018
www.dynamicpapers.com
Marks
5
Constructor method header taking 2 parameters (with correct data types if given)
Checking if Number > = 0 and < = 9
Checking theShape is ‘square’ or ‘triangle’ or ‘circle’
« if both valid assigning Number and Shape the parameters
« if either invalid report error (output/returning value/catching error)
Page 13 of 18
9608/41
Cambridge International AS/A Level – Mark Scheme
PUBLISHED
Question
5(b)
October/November 2018
www.dynamicpapers.com
Answer
Examples:
Python
def __init__(self, Num, theShape):
if (Num >= 0 and Num <= 9) and (theShape = "square" or theShape = "triangle" or
theShape = "circle”) :
self.
__Number = Num
self.__Shape = TheShape
else
print("Error")
endif
VB.NET
Public Sub New(Num As Integer, theShape As String)
IF (Num >= 0 and Num <= 9) and (theShape = "square" or theShape = "triangle" or
theShape = "circle") THEN
Number = Num
Shape = theShape
ELSE
Console.WriteLine("Error")
ENDIF
End Sub
Pascal
constructor Cards.Create(Num : Integer, theShape : String);
begin
If (Num >= 0 and Num <= 9) and (theShape = "square" or theShape = "triangle" or theShape =
"circle")
Number := Num;
Shape := theShape;
Else
Writeln("Error")
;
end;
© UCLES 2018
Page 14 of 18
Marks
9608/41
Cambridge International AS/A Level – Mark Scheme
PUBLISHED
Question
5(c)
Answer
1 mark per bullet point to max 2:
•
•
Marks
2
Function declaration for GetNumber
Returning Number
Examples:
Python
def GetNumber():
return(self.__Number)
VB.NET
Public Function GetNumber() As Integer
Return(Number)
End Function
Pascal
function Cards.GetNumber() : Integer;
begin
GetNumber := Number;
end;
© UCLES 2018
October/November 2018
www.dynamicpapers.com
Page 15 of 18
9608/41
Cambridge International AS/A Level – Mark Scheme
PUBLISHED
Question
5(d)
Answer
1 mark per bullet point to max 2:
•
•
October/November 2018
www.dynamicpapers.com
Marks
2
Assigning to OneS and correct instantiation
Correct parameter values
Examples:
Python
OneS = Cards(1, "square")
VB.NET
Dim OneS As New Cards(1, "square")
or
Dim OneS As Cards = New Cards(1, "square")
or
OneS = New Cards(1, "square")
Pascal
var OneS : Cards;
OneS := Cards.Create(1, "square")
5(e)
1 mark per bullet point:
•
•
•
•
•
•
© UCLES 2018
6
function declaration (returning integer) and taking 2 cards as parameter
comparison of Number and Shape «
« if the same output ‘SNAP’ and return –1
Compare Number of each to find highest and return the highest number
return either number if the same
correct use of .GetNumber() and .GetShape()throughout
Page 16 of 18
9608/41
Cambridge International AS/A Level – Mark Scheme
PUBLISHED
Question
5(e)
Answer
Examples:
Python
def Compare(P1Card, P2Card):
if P1Card.GetNumber() = P2Card.GetNumber() AND
P1Card.GetShape() = P2Card.GetShape():
Print("SNAP")
return -1
elif P2Card.GetNumber() > P1Card.GetNumber():
return P2Card.GetNumber()
else:
return P1Card.GetNumber()
VB.NET
Function Compare(P1Card As Cards, P2Card As Cards) As Integer
IF P1Card.GetNumber() = P2Card.GetNumber()AND
P1Card.GetShape() = P2Card.GetShape()THEN
Console.writeline("SNAP")
Return -1
ELSEIF P2Card.GetNumber() > P1Card.GetNumber() THEN
P2Card.GetNumber()
ELSE
Return P1Card.GetNumber()
ENDIF
End Function
© UCLES 2018
Page 17 of 18
October/November 2018
www.dynamicpapers.com
Marks
9608/41
Cambridge International AS/A Level – Mark Scheme
PUBLISHED
Question
5(e)
Answer
Pascal
function Compare(P1Card : Cards, P2Card : Cards) : Integer;
begin
if P1Card.GetNumber() = P2Card.GetNumber()AND
P1Card.GetShape() = P2Card.GetShape() then
writeline("SNAP");
return −1;
else if P2Card.GetNumber() > P1Card.GetNumber() then
return P2Card.GetNumber();
else
return P1Card.GetNumber();
end;
© UCLES 2018
Page 18 of 18
October/November 2018
www.dynamicpapers.com
Marks