Computer Science (9608) · Oct/Nov 2017 · Mark scheme 22
Cambridge Computer Science (9608) mark scheme for paper 22, Oct/Nov 2017 — 9608/22/O/N/17, file 9608_w17_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 2017
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 2017 series for most
®
Cambridge IGCSE , Cambridge International A and AS Level components and some Cambridge O Level
components.
® IGCSE is a registered trademark.
This document consists of 12 printed pages.
© UCLES 2017
[Turn over
9608/22
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2017
PUBLISHED
Question
Answer
1(a)(i)
Marks
6
Data value
FALSE
03/03/2013
35
"INTEGER"
3.5
"35"
Data type
BOOLEAN
DATE // DATETIME
INTEGER
STRING
REAL
STRING
One mark for each data type
Mark first data type given in each case
1(a)(ii)
1D Array // 1D List
1
1(a)(iii)
Ability to recognise:
• selection statement
• iteration statement
• assignment statements
• data declarations / structures / data types / use of variables or objects
• modular structure / functions / procedures / subroutines
• subroutine parameters
• Specific types of statement e.g. Input, Output, File operations
• Code format
• Operators
2
Mark as follows:
Any two from above, or valid alternative
Accept by example
1(b)(i)
2
Data
67 // 0100 0011 // 043h
65 // 0100 0001 // 041h
71 // 0100 0111 // 047h
69 // 0100 0101 // 045h
One mark for 67 and 65
One mark for 71 and 69
Accept binary, denary or hex values (hex must be clearly indicated)
Max one mark if blank cell anywhere in sequence
Ignore any data values before or after the four characters
© UCLES 2017
Page 2 of 12
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2017
PUBLISHED
9608/22
Question
1(b)(ii)
Answer
• A value representing the number of characters ... ... stored at beginning of string
OR
• Terminator / special character ... ... stored to indicate the end of string
Marks
2
One mark for each phrase or equivalent.
1(c)
Explanation includes:
• to pass values to/from the subroutine
• to produce re-useable code
• to avoid global variables
• to allow recursion
Max 3
One mark per answer
1(d)(i)
27: MyGrade assigned the value "Fail"
2
101: Output the text "Invalid Value Entered"
Ignore minor spelling mistakes
1(d)(ii)
IF MyMark >= 75 AND MyMark <=100
THEN
MyGrade ← "Distinction"
ELSE
IF MyMark >= 35 AND MyMark <=74
THEN
MyGrade ← "Pass"
ELSE
IF MyMark >= 0 AND MyMark <=34
THEN
MyGrade ← "Fail"
ELSE
ENDIF
OUTPUT "Invalid value entered"
ENDIF
ENDIF
One mark for each of:
•
•
•
•
•
One correct range test
‘IF’ equivalent (nested or not) to three CASE range tests...
... with three corresponding assignments
Equivalent of CASE OTHERWISE with corresponding OUTPUT statement
Matching (three) ENDIFs (Or one if ELSIFs used)
Max 4 if solution doesn't work under all circumstances // is not functionally equivalent to
CASE
© UCLES 2017
Page 3 of 12
5
Cambridg
ge Internatio
onal AS/A Level
L www.dynamicpapers.com
– Mark Scheme
Octobe
er/Novembe
er
201
17
P
PUBLISHED
D
9608/22
9
Ques
stion
2(a
a)
Answerr
Marrk as followss:
•
•
•
Max 2
To search for a given value in the
e array
on in the arrray if the search value is found
and outputt the positio
if search value
v
not fou
und then ou
utput “Not fo
ound”
2(b
b)
© UCLES 2017
M
Marks
9
Page 4 of 12
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2017
PUBLISHED
9608/22
Question
2(b)
Answer
Marks
Mark as follows:
• One mark for START and STOP / END
• One mark for each bracketed pair
• One mark for each of other labelled symbol (decision box shape must be correct)
• Allow F/T from incorrect decision symbol
Full marks should be awarded for functionally equivalent solutions.
Question
Answer
Marks
3
Max 8
Line
number
Error
01
Wrong procedure name
– "SortArray"
PROCEDURE ArraySort
02
Wrong data type - CHAR
DECLARE Temp: STRING
03
Variables undefined
DECLARE FirstID, SecondID, I, J :
INTEGER
04
Wrong 'Value2' of 100
FOR I ← 1 TO 99
05
Wrong range
FOR J ← 1 TO (100 – I)
06/07
Wrong function MODULUS
06/07
Wrong value of 6
Replace MODULUS with TONUM:
FirstID ← TONUM(LEFT(Product[J],
Should be 4:
FirstID ← TONUM(LEFT(Product[J],
10
11
13/14
Assigning wrong value
to Temp
Assigning wrong value
to Product[I]
Lines reversed
Correction
Temp ← Product[J]
Product[J] ← Product[J + 1]
13 ENDIF
14 ENDFOR
One mark for each correct row
© UCLES 2017
Page 5 of 12
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2017
PUBLISHED
9608/22
Question
4(a)
Answer
Marks
Pseudocode solution included here for development and clarification of mark scheme.
Programming language solutions appear in the Appendix.
PROCEDURE
DECLARE
DECLARE
DECLARE
DECLARE
TestRandom (Repetitions : INTEGER)
Frequency : ARRAY [1 : 10] OF INTEGER
Expected : REAL / INTEGER //allow either
NextRandom : INTEGER
N : INTEGER
FOR N ← 1 TO 10
Frequency[N] ← 0
ENDFOR
Expected ← INT(Repetitions / 10)
CALL RANDOMIZE()
//Set random seed
FOR N ← 1 TO Repetitions
NextRandom ← INT(RND() * 10) + 1
Frequency[NextRandom] ← Frequency[NextRandom] + 1
ENDFOR
OUTPUT "The expected frequency is " & Expected
OUTPUT "Number
Frequency
Difference"
FOR N ← 1 TO 10
OUTPUT N & "
" & Frequency[N] & "
" & Frequency[N] –
Expected
ENDFOR
ENDPROCEDURE
Mark as follows:
1. Procedure heading (including parameter)
2. Array declaration – 10 or 11 elements
3. Array declaration – data type
4. Variable declaration for a loop counter (integer) or expected frequency (integer or
real)
5. Variable declaration for next random value
(For Python solutions, mark points 1 to 4 may be gained by suitable comments)
6.
7.
8.
© UCLES 2017
Initialise all elements of array
To set all elements to zero
Calculate expected frequency
Page 6 of 12
16
9608/22
Question
4(a)
4(b)
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2017
PUBLISHED
Answer
9.
10.
11.
12.
Loop to generate required number of random values
Use of relevant RANDOM() function in a loop
Generate random integer value in the range 1 to 10 in a loop
Increment (array) element in a loop
13.
14.
15.
16.
Output expected frequency message not in any loop
Output column header text
(Loop to) output each row
... including three correct values (spaces optional)
•
Single-stepping
– to allow program statements to be executed one at a time
Breakpoints
– to pause / stop the program at a specific line / statement
Variable / expression watch window
– to monitor the value of variables / expressions as the program is run
•
•
Marks
6
One mark for each Feature (text as above or equivalent) + 1 for meaningful explanation
of use in context.
4(c)
Program is probably working correctly if:
• Header is present giving frequency as 20
• Column headers are present
• All rows are present (1 to 10)
• The difference is calculated correctly
• Output is formatted correctly
• Total differences should be zero
• Sum of Frequencies should be 200
© UCLES 2017
Page 7 of 12
Max 2
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2017
PUBLISHED
9608/22
Question
5
Answer
PROCEDURE RemoveDetails
DECLARE FileLine: STRING
DECLARE MemberToDelete: STRING
OPENFILE "EmailDetails.txt" FOR READ
OPENFILE "NewEmailDetails.txt" FOR WRITE
INPUT MembershipNumber
WHILE NOT EOF("EmailDetails.txt")
READFILE "EmailDetails.txt", FileLine
IF LEFT(FileLine, 4) <> MembershipNumber
THEN
WRITEFILE "NewEmailDetails.txt", FileLine
ENDIF
ENDWHILE
CLOSEFILE "EmailDetails.txt"
CLOSEFILE "NewEmailDetails.txt"
ENDPROCEDURE
Mark as follows:
1. Procedure declaration and end. No parameters.
2.
Variable declaration of STRING for variable FileLine (or similar)
3.
Input the MembershipNumber of the person who has left
4.
Open EmailDetails for READ
5.
Open NewEmailDetails for WRITE
6.
Correct loop checking for EOF(EmailDetails)
7.
Reading a line from EmailDetails.txt in a loop
8.
Correct check for MemberToDelete in a loop
9.
Writing a line to NewEmailDetails.txt in a loop
10. Closing both files (not in a loop)
© UCLES 2017
Page 8 of 12
Marks
Max 9
9608/22
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2017
PUBLISHED
Appendix - Program Code Example Solutions
Q4 (a): Visual Basic
Dim random As New Random()
Sub TestRandom(ByVal repetitions As Integer)
Dim randinrange As Integer
Dim i As Integer
Dim num(1 To 10) As Integer
Dim freq As Integer
Dim difference As Integer
freq = repetitions / 10
'calculate expected frequency
For i = 1 To 10
num(i) = 0
Next i
'initialise array to store total frequencies
For i = 1 To repetitions 'generate random numbers & increment
appropriate freq
randinrange = random.Next(1, 11)
num(randinrange) = num(randinrange) + 1
Next i
Console.WriteLine("The expected frequency is " & freq)
Console.WriteLine("Number
Frequency
Difference")
'report header
'column headers
For i = 1 To 10
'calc & display difference between expected and actual
freq
difference = num(i) - freq
Console.WriteLine(i & "
" & num(i) & "
" & difference)
Next i
End Sub
Other possible ways of calculating a random number in VB include:
randinrange = CInt(Math.Floor((upperbound - lowerbound + 1) * Rnd())) +
lowerbound
randinrange = math.round((Rnd()*9)+1)
randinrange = CInt(Math.Ceiling(Rnd() * 9
© UCLES 2017
Page 9 of 12
9608/22
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2017
PUBLISHED
Q4 (a): Pascal
procedure TestRandom(var Repetitions : integer);
var
Frequency : array[1..10] : integer;
Expected, NextRandom, N : integer;
begin
Expected := Round(Repetitions/10);
for N := 1 to 10 do
Frequency[N] := 0;
for N := 1 to Repetitions do
begin
NextRandom := random(10)+1;
Frequency[NextRandom] := Frequency[NextRandom]+1;
end;
writeln ('The expected frequency is ', Expected);
writeln ('Number Frequency Difference');
for N := 1 to 10 do
writeln ('
',N,'
Expected);
',Frequency[N],'
end;
© UCLES 2017
Page 10 of 12
',Frequency[N]-
9608/22
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2017
PUBLISHED
Q4 (a): Python
# frequency is an array from 1 to 10 of type integer;
# nextNumber is an integer which stores the created random number
# expected is an integer which stores the expected frequency of each number
def TestRandom (repetitions):
import random
frequency = [0 for i in range(1,11)]
to 0
# initialise each frequency count
expected = repetitions / 10
for i in range(1, repetitions + 1):
nextNumber = random.randint(1,10)
frequency[nextNumber] = frequency[nextNumber]+ 1
print ("The expected frequency is ", expected)
print("
Number Frequency Difference")
for i in range(1,11):
print ("
", i, "
expected)
", frequency[i],"
", frequency[i] -
Alternative:
def TestRandom (repetitions):
expected = repetitions / 10
## initialised as real/integer
## NextRandom and N defined as integers
frequency =[0,0,0,0,0,0,0,0,0,0,0] ## defined as an array and
initialised to zero
for n in range (0,repetitions):
nextNumber = randint(1, 10)
frequency[nextNumber] += 1
print ('The expected frequency is ', expected)
print ('Number Frequency Difference')
for n in range (1, 11):
print (n,'
',frequency[n],'
',frequency[n] - expected)
Alternative:
frequency =[0]*11
frequency =[]
## alternate way to initialise array to zero
## empty array/list
Alternative:
for n in range (1,11):
frequency[n-1] = 0
© UCLES 2017
##alternate way to initialise array to zero
Page 11 of 12
9608/22
Cambridge International AS/A Levelwww.dynamicpapers.com
– Mark Scheme
October/November
2017
PUBLISHED
Alternative:
for n in range (0,11): ##alternate way to initialise array to zero
frequency.append(0)
© UCLES 2017
Page 12 of 12