Computer Science (9608) · May/June 2016 · Mark scheme 42
Cambridge Computer Science (9608) mark scheme for paper 42, May/June 2016 — 9608/42/M/J/16, file 9608_s16_ms_42.pdf.
Text of this paper
www.dynamicpapers.com
Cambridge International Examinations
Cambridge International Advanced Level
COMPUTER SCIENCE
9608/42
Paper 4 Written Paper
May/June 2016
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 will not enter into discussions about these mark schemes.
Cambridge is publishing the mark schemes for the May/June 2016 series for most Cambridge IGCSE®,
Cambridge International A and AS Level components and some Cambridge O Level components.
® IGCSE is the registered trademark of Cambridge International Examinations.
This document consists of 15 printed pages.
© UCLES 2016
[Turn over
www.dynamicpapers.com
Pag
P ge 2
Mar
M k Sch
S hem
me
e
C mb
Cam
brid
dge
e In
nte
ern
natiion
nal A Le
eve
el – May
M y/J
Jun
ne 2016
6
Q estio
Qu
on
1
(a)) (i)
(
Sylllab
bus
9 08
960
Pape
P
er
4
42
A
An
nsw
werr
Mark
ks
TY
YPE
E Lin
L nk
ked
dLi
ist
t
1
(D
DEC
CLA
ARE
E) S
Sur
rna
ame
e : ST
TRI
ING
G
(D
DEC
CLA
ARE
E) P
Ptr
r : IN
I TE
EGE
ER
1
EN
NDT
TYP
PE
1
Ac
cce
eptt:
Li
ink
ked
dList : RE
ECO
ORD
1
Su
urn
nam
me : S
STR
RIN
NG
Pt
tr : IN
NTEG
GER
R
1
EN
NDR
REC
COR
RD
D
1
Ac
cce
eptt:
TY
YPE
E Lin
L nk
ked
dLi
ist
t = RE
ECO
ORD
D
1
Su
urn
nam
me : S
STR
RIN
NG
Pt
tr : IN
NTEG
GER
R
1
EN
NDT
TYP
PE / E
END
DRE
ECO
ORD
1
Ac
cce
eptt:
ST
TRU
UCT
TUR
RE L
Lin
nke
edL
List
t
1
(D
DEC
CLA
ARE
E) S
Sur
rna
ame
e : ST
TRI
ING
G
(D
DEC
CLA
ARE
E) P
Ptr
r : IN
I TE
EGE
ER
1
EN
NDS
STR
RUCTUR
RE
1
3
Accce
ept AS
S / O
OF in
nste
ead o
of :
(iii)
(D
DEC
CLA
ARE
E) S
Sur
rna
ame
eLis
st[
[1:
:50
000
0] : Lin
L nke
edL
List
t
2
Accce
ept AS
S / O
OF in
nste
ead o
of :
Accce
ept () insttea
ad of []
Accce
ept witho
outt lowe
er bou
b und
d
Ind
dex
x sep
s para
ato
or can
c n be
e , : ...
(b)) (i)
(
(iii)
(c)) (i)
(
Wu
u
Accce
ept with quote
es
1
6
1
Is
sFo
oun
nd + relevantt descrip
ptio
on
BO
OOL
LEA
AN
© Ca
amb
brid
dge
e In
nterrnattion
nal Ex
xam
mina
atio
ons
s 20
016
6
1
1
2
www.dynamicpapers.com
Page 3
Mark Scheme
Cambridge International A Level – May/June 2016
Question
(ii)
Syllabus
9608
Answer
Accept () instead of []
01 Current ← StartPtr
Paper
42
Marks
6
02 IF Current = 0
03
04
05
THEN
OUTPUT "Empty List" (or similar message)
(accept without quotes) Reject “Error”
ELSE
07
IsFound ← FALSE
INPUT ThisSurname
08
REPEAT
09
IF SurnameList[Current].Surname = ThisSurname
10
THEN
11
12
IsFound ← TRUE
OUTPUT "Surname found at position ", Current
13
ELSE
14
// move to the next list item
15
16
Current ← SurnameList[Current].Ptr
ENDIF
17
UNTIL IsFound = TRUE OR Current = 0
18
IF IsFound = FALSE
19
THEN
20
OUTPUT "Not Found"
21
ENDIF
06
22 ENDIF
Accept = for assignment
2
(a) (i)
(ii)
A procedure which is defined in terms of itself // A procedure which makes a call to
itself // A procedure that calls itself
1
08 // 8
1
© Cambridge International Examinations 2016
www.dynamicpapers.com
Page 4
Mark Scheme
Cambridge International A Level – May/June 2016
Question
Syllabus
9608
Answer
(b) (i)
Paper
42
Marks
4
MyList
Index
Item
1
2
3
4
5
6
7
8
9
10
1
9
3
5
8
9
13
16
27
0
0
0
2
3
4
5
13
16
27
6
0
7
8
Note: Final mark only if no additional entries in table
Accept last row to show all final values
(ii)
Any one from:
Deletes/removes parameter value/ Item (from the array MyList)
// Deletes the first entry (in MyList) that equals or is bigger than Item
Overwrites Item by moving subsequent items up/down/across/left R right
© Cambridge International Examinations 2016
1
www.dynamicpapers.com
Page 5
Mark Scheme
Cambridge International A Level – May/June 2016
Question
3
Syllabus
9608
Paper
42
Answer
(a)
Marks
7
HIRE-TRANS
F_BODY
F_TRAILER
TRANS
Customer
data
CustomerID
Customer
Name
Hire data
Car Reg
Hire start
date
Number of
days hired
Mark as follows:
Label F_TRAILER
Label TRANS
1
1
Customer box (Accept label Customer)
Hire box (Accept label Hire)
1
1
Customer fields : Customer Name, CustomerID/IDnumber
Hire fields: Car Reg
Hire fields: Hire start date, Number of days hired
1
1
1
accept level 5 fields in any order
Ignore parent
© Cambridge International Examinations 2016
www.dynamicpapers.com
Page 6
Question
Mark Scheme
Cambridge International A Level – May/June 2016
Syllabus
9608
Paper
42
Answer
Marks
5
(b)
Mark as follows:
Selection symbol x 2 (Car-hire / No car-hire)
Labelling for CAR_HIRE / NO_HIRE (accept similar labels*)
Labelling for Car registration and Car total / Total hires
Iteration symbol for HIRE (accept in HIRE_LIST as a BOD)
Labelling for start date and number of days (as per diagram)
* For CAR_HIRE label:
Accept: Hires / hired / Car data / hire data / hire record / one or more hires
© Cambridge International Examinations 2016
1
1
1
1
1
www.dynamicpapers.com
Page 7
Mark Scheme
Cambridge International A Level – May/June 2016
Question
4
(a) (i)
(ii)
(b)
Syllabus
9608
Paper
42
Answer
Marks
a03, h07, a23
accept in any order, must be lower case
1
The car must pass (both) brake test and tyres test
1
retestAllowed(ThisCar)
1
If (testBrakes(ThisCar, pass) and testTyres(ThisCar, fail))
3
1
or (testBrakes(ThisCar, fail) and testTyres(ThisCar, pass))
1
(one mark per bold underlined all correct)
accept another variable instead of ThisCar, but must be same throughout.
(c) (i)
2
a07
[p03]
must be []
must be lower case, but don’t penalise twice, so follow through from part(b)
(ii)
[p05,m04]
1
(iii)
[ ]
1
[ ]
1
(d)
5
(a) (i)
Mark
Description
3
Expected result (Grade)
Normal
FAIL/PASS/MERIT/DISTINCTION
Abnormal
Error
Extreme/Boundary
FAIL/PASS/MERIT/DISTINCTION
3 × (mark + matching grade)
for abnormal data accept negative values, non-integer values, Expected Result: Error
0 and marks above 100 are still acceptable values
Do not accept FAIL in expected result column for Abnormal data
(ii)
(b)
(The programmer is) concerned only with the input (i.e. the mark) to the function and
monitoring the expected output (i.e. the grade)
// can compare expected result and actual result
1
Exception:
1. situation causing a crash / run-time error / fatal error
3
1
Exception handling:
2. code which is called when a run-time error occurs
3. … to avoid the program terminating/crashing
1
1
© Cambridge International Examinations 2016
www.dynamicpapers.com
Page 8
Mark Scheme
Cambridge International A Level – May/June 2016
Question
6
Paper
42
Answer
(c)
1
2
3
4
5
6
(d) (i)
09 // 9
(ii)
Syllabus
9608
1
2
3
4
5
6
7
Marks
Max 3
Open a non-existent file
Directory path does not exist
Attempt to read past the end of the file // attempt to read an empty file
Array subscript is out of range
Non-integer value / corrupt data read
File already open in a different mode // wrong file permissions
1
Line 11 catches exceptions (only) between lines 05 and 10
Line 11 stops the program from crashing
Different exception types recognised
Each exception type has an appropriate message output
The program language has an (object) type EXCEPTION
ThisException is the instance of EXCEPTION which has been raised
EXCEPTION objects have a ‘Message’ property
// the message property for ThisException is
“Arithmetic operation resulted in an overflow”
(a)
1
1
1
1
1
1
Max 3
1
4
Max 3 marks if extra states/transitions added.
© Cambridge International Examinations 2016
www.dynamicpapers.com
Page 9
Question
(b) (i)
(ii)
Mark Scheme
Cambridge International A Level – May/June 2016
Syllabus
9608
Paper
42
Answer
Marks
Mark as follows:
1 Declaration for array (character or string data type)
2 FOR loop for x going from 1 to 8, generating column index used in array
3 FOR loop for y going from 1–2, 3–6, 7–8
(Accept all squares being set to 'E' and then overwritten with 'B', 'W'
respectively)
4 Setting squares to 'B', 'E', 'W' (must be in quotes, accept single or double)
4
Mark as follows:
1 Procedure heading and declaration of 2 local variables
2 Establishing the stopper colour – opposite to the mover
3 Test for piece in column 1 (x>1) // column 8 (x<8)
4 Test for ‘E’
5 Correct method for moving left // for moving right
6 until edge of board reached
7 until other colour (stopper colour) encountered
8 until own colour encountered (PieceColour)
9 Correct output for cell indexes
(accept for moving in 1 direction only)
10 including the ‘REMOVE’ message
Max 5
1
1
1
1
1
1
1
1
1
1
Note: must use given parameter identifiers: PieceColour, xCurrent, yCurrent
(c) (i)
Classes could be designed for :
• the board
• a piece
Containment (Board contains Pieces)
The pieces are instances/objects (of the Piece class)
© Cambridge International Examinations 2016
Max 2
www.dynamicpapers.com
Page 10
Mark Scheme
Cambridge International A Level – May/June 2016
Question
(ii)
Answer
Accept any reasonable answer, for example:
BOARD class:
Properties:
• Number of squares / size / dimensions
• Current state of all squares
Methods: –
• Set the starting board
• Capture the finishing state of the board
• Display the state of the board after each move
PIECE class:
Properties:
• Starting x position
• Starting y position
• Current x position
• current y position
• Colour
• State / Removed / Active
Methods:
• Move piece
• Remove piece
Mark as follows:
two correct responses are worth 1 mark
Accept other classes: Game, Player
© Cambridge International Examinations 2016
Syllabus
9608
Paper
42
Marks
Max 2
www.dynamicpapers.com
Page 11
Mark Scheme
Cambridge International A Level – May/June 2016
Programming code
6
(b) (i)
VB.NET
Dim Board(8, 8) As Char
Dim Row, Column As Integer
For Row = 1 To 2
For Column = 1 To 8
Board(Row, Column) = "B"
Next
Next
For Row = 3 To 6
For Column = 1 To 8
Board(Row, Column) = "E"
Next
Next
For Row = 7 To 8
For Column = 1 To 8
Board(Row, Column) = "W"
Next
Next
PASCAL
var Row, Column : integer;
Board : array[1..8, 1..8] of char;
begin
for Row := 1 to 2 do
for Column := 1 to 8 do
Board[Row, Column] := 'B';
for Row := 3 to 6 do
for Column := 1 to 8 do
Board[Row, Column] := 'E';
for Row := 7 to 8 do
for Column := 1 to 8 do
Board[Row, Column] := 'W';
end.
© Cambridge International Examinations 2016
Syllabus
9608
Paper
42
www.dynamicpapers.com
Page 12
Mark Scheme
Cambridge International A Level – May/June 2016
Syllabus
9608
Paper
42
PYTHON
Board = [["" for j in range(9)] for i in range(9)]
for Row in range(1, 3) :
for Column in range(1, 9) :
Board[Row][Column] = "B"
for Row in range(3, 7) :
for Column in range(1, 9) :
Board[Row][Column] = "E"
for Row in range(7, 9) :
for Column in range(1, 9) :
Board[Row][Column] = "W"
Alternative declarations of Board array :
Board = [[""] * 9 for i in range(9)]
Board = [[]]
for i in range(9) :
for j in range(9) :
Board.append("")
Instead of initialising with empty string, could initialise with ‘E’. this would then only require ‘B’ and ‘W’
loops later.
For example:
Board = [["E"] * 9 for i in range(9)] // Board =[["E"]*9]*9
for Row in range(1, 3) :
for Column in range(1, 9) :
Board[Row][Column] = "B"
for Row in range(7, 9) :
for Column in range(1, 9) :
Board[Row][Column] = "W"
Board =[]
for i in range(9):
Board.append(["E"]*9)
© Cambridge International Examinations 2016
www.dynamicpapers.com
Page 13
6
Mark Scheme
Cambridge International A Level – May/June 2016
Syllabus
9608
(b) (ii)
VB.NET
Sub ValidMoves(ByVal PieceColour As Char, ByVal xCurrent As Integer,
ByVal yCurrent As Integer)
Dim i As Integer
Dim StopperColour As Char
Dim NoFurther As Boolean
If PieceColour = "B" Then
StopperColour = "W"
Else
StopperColour = "B"
End If
Console.WriteLine("Possible moves are : ")
If xCurrent <> 1 Then
Console.WriteLine("Moving LEFT . . .")
i = xCurrent – 1
NoFurther = False
do
if Board(i, yCurrent) = "E" Then
Console.WriteLine(i & " " & yCurrent)
End If
if Board(i, yCurrent) = StopperColour Then
Console.WriteLine(i & " " & yCurrent & " REMOVE PIECE")
NoFurther = True
End If
i = i – 1
Loop Until i = 0 Or NoFurther = True
End If
if xCurrent <> 8 Then
Console.WriteLine("Moving RIGHT . . .")
i = xCurrent + 1
NoFurther = False
do
if Board(i, yCurrent) = "E" :
Console.WriteLine(i & " " & yCurrent)
End If
if Board(i, yCurrent) = StopperColour Then
Console.WriteLine(i & " " & yCurrent & " REMOVE PIECE")
NoFurther = True
End If
i = i + 1
Loop Until i = 9 Or NoFurther = True
End If
End Sub
© Cambridge International Examinations 2016
Paper
42
www.dynamicpapers.com
Page 14
Mark Scheme
Cambridge International A Level – May/June 2016
Syllabus
9608
Paper
42
PASCAL
procedure ValidMoves(PieceColour : char; xCurrent, yCurrent : integer);
var StopperColour : char;
i : integer;
NoFurther : boolean;
begin
if (PieceColour = 'B') then
StopperColour := 'W'
else
StopperColour := 'B';
writeln('Possible moves are : ');
if (xCurrent <> 1) then
begin
writeln('Moving LEFT . . . ');
i := xCurrent – 1;
NoFurther := false;
repeat
if (Board[i, yCurrent] = 'E') then
writeln(intToStr(i) + ' ' + intToStr(yCurrent));
if (Board[i, yCurrent] = StopperColour) then
begin
writeln(intToStr(i) + ' ' + intToStr(yCurrent) + ' REMOVE
PIECE');
NoFurther := true;
end;
i := i – 1;
until ((i = 0) or (NoFurther = true));
end;
if (xCurrent <> 8) then
begin
writeln('Moving RIGHT . . . ');
i := xCurrent + 1;
NoFurther := false;
repeat
if (Board[i, yCurrent] = 'E') then
writeln(intToStr(i) + ' ' + intToStr(yCurrent));
if (Board[i, yCurrent] = StopperColour) then
begin
writeln(intToStr(i) + ' ' + intToStr(yCurrent) + ' REMOVE
PIECE');
NoFurther := true;
end;
i := i + 1;
until ((i = 9) or (NoFurther = true));
end;
end;
© Cambridge International Examinations 2016
www.dynamicpapers.com
Page 15
Mark Scheme
Cambridge International A Level – May/June 2016
Syllabus
9608
PYTHON
def ValidMoves(PieceColour, xCurrent, yCurrent) :
if PieceColour == "B" :
StopperColour = "W"
else :
StopperColour = "B"
print("Possible moves are : ")
if xCurrent != 1 :
print("Moving LEFT . . .")
i = xCurrent – 1
NoFurther = False
while i > 0 and NoFurther == False :
if Board[i][yCurrent] == "E" :
print(str(i) + " " + str(yCurrent))
if Board[i][yCurrent] == StopperColour :
print(str(i) + " " + str(yCurrent) + " REMOVE PIECE")
NoFurther = True
i = i – 1
if xCurrent != 8 :
print("Moving RIGHT . . .")
i = xCurrent + 1
NoFurther = False
while i < 9 and NoFurther == False :
if Board[i][yCurrent] == "E" :
print(str(i) + " " + str(yCurrent))
if Board[i][yCurrent] == StopperColour :
print(str(i) + " " + str(yCurrent) + " REMOVE PIECE")
NoFurther = True
i = i + 1
© Cambridge International Examinations 2016
Paper
42