Computer Science (9608) · Oct/Nov 2021 · Mark scheme 23

Cambridge Computer Science (9608) mark scheme for paper 23, Oct/Nov 2021 — 9608/23/O/N/21, file 9608_w21_ms_23.pdf.

Advertisement
Loading the paper…
Text of this paper

Cambridge International AS & A Level
COMPUTER SCIENCE

9608/23

Paper 2 Fundamental Problem-Solving and Programming Skills

October/November 2021

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 2021 series for most
Cambridge IGCSE™, Cambridge International A and AS Level components and some Cambridge O Level
components.

This document consists of 17 printed pages.
© UCLES 2021

[Turn over

9608/23

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

October/November
2021

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 2021

Page 2 of 17

9608/23

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question

October/November
2021

Answer

Marks

1(a)(i)

One mark for each bullet point to Max 2
• OUTPUT "Enter product number: "
• INPUT ProductNumber

2

1(a)(ii)

One mark for:
• Store / write the product number / data // retrieve data at a later date

1

One mark for each bullet point to Max 2
• (Visual method ) making it easier to understand / representing / follow the
logic of program structures / algorithm
• Overview of the process, allowing logical errors to be identified
• Provides documentation for other programmers / non-programmers

2

1(b)

1(c)

Technical term

Description

Corrective maintenance

Stores data of the same data type
in memory

Array

Amends an algorithm following
identification of errors

3

Amends an algorithm in response
to specification changes

Adaptive maintenance

Shows parameters passed
between program modules

Structure chart
One mark for 2 correct
Two marks for 3 correct
1(d)

One mark for each correct row

5

Pseudocode expression

© UCLES 2021

Evaluates to

EndOfYear * Limit / Mileage

100

LENGTH(Description) / NUM_TO_STRING(Limit)

ERROR

MOD(20, LENGTH(Destination))

2

(EndOfYear < 2) AND (Limit = 20000)
AND NOT(Overdue)

TRUE

MID(Description, 1, 5) & LEFT(Destination,
2) & NUM_TO_STRING(Limit / 1000)

"CONCREL20"

Page 3 of 17

9608/23

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
2(a)

October/November
2021

Answer
One mark for each correct row

Marks
4

Line number

Corrected pseudocode statement

04
06

Procedure SetOut()// (No parameter as size is input)
INPUT (Size)
(Add line 6)

05

DECLARE Index : INTEGER

07

FOR Index ← 1 TO 50

08

IF Size = CarSize[Index] AND
Available[Index] = TRUE

2(b)

One mark for each bullet point
• Loop from 1 to 50 / loop for all the number of cars the company owns
• Compare the input / parameter value to the array CarSize
[counter]
• … and the corresponding element in the array Available is set to TRUE
/ the car is available
• If so, output the current loop counter (the car number), the (parameter)
Size followed by "Available"

4

2(c)

FUNCTION PayUsingAccount(Balance : REAL,
CostOfHire : REAL) RETURNS BOOLEAN

3

IF CostOfHire > Balance
THEN
RETURN FALSE
ELSE
RETURN TRUE
ENDIF
ENDFUNCTION
One mark for each of the following:
1
2
3

© UCLES 2021

Function heading and ending including parameters and CostOfHire as
REAL.
If CostOfHire > Balance
Return of True / False

Page 4 of 17

9608/23

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
3(a)

October/November
2021

Answer
One mark for Start and Stop symbols
One mark for each outlined group
1

(Prompt and) input EmailString

2

Call to Split() twice to obtain Domain and User substrings

3

Call to IsLowerCase() in decision box with User parameter

4

Call to IsThreeLetter() in decision box with Domain parameter and
return "Invalid" if both false

5

Return EmailString only if all decisions evaluate to TRUE

MPs 4 and 5 may be combined using AND

© UCLES 2021

Page 5 of 17

Marks
6

9608/23

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question

October/November
2021

Answer

Marks

START

OUTPUT "Enter address: "
INPUT EmailString

Set Domain TO
Split(EmailString, FALSE)

Set User TO
Split(EmailString, TRUE)

NO
IsLowerCase(User) = TRUE ?

YES
NO
IsThreeLetter (Domain) =
TRUE ?

YES

Return EmailString

END

© UCLES 2021

Page 6 of 17

Return
"Invalid"

9608/23

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
3(b)

October/November
2021

Answer

Marks

One mark for each bullet point to Max 2.
• StartLine/ LastLine is out of range
• StartLine is after LastLine //
• LastLine is before StartLine
• LastLine does not exist

2

3(c)(i)

One mark for each bullet point
Explanation
• An error in the grammar of the programming language
• An error that breaks the rules of the programming language

2

3(c)(ii)

One mark for each bullet point to Max 1
Examples are shown in pseudocode for reference only.
• DECLARE NUMBER AS INTEGER
NUMBER ← "LEFT"
• IF …
ENDWHILE
• Flag ← TRUE + 3

1

One mark for each bullet point
• Both module names: Split() and IsLowercase()
• Two parameters to Split() and one parameter returned from Split()
(as shown)
• All remaining parameters

3

3(d)

AddressChecker()

Split()

© UCLES 2021

IsLowerCase()

Page 7 of 17

IsThreeLetter()

9608/23

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

October/November
2021

Question

Answer

3(e)

One mark for the feature. One mark for the description of the feature to
Max 4.
• Feature: Single stepping. Description: Execute each instruction one at a
time.
• Feature: Breakpoints. Description: Line/lines in the program code at
which point the program stops execution.
• Feature: Variable / expression watch windows. Description: Windows that
display the values assigned to variables/expressions as the program
executes.

Question
4(a)

4(b)(i)

Answer

© UCLES 2021

5

FileLine

Counter

1

0

2

0

"XD43688"

FALSE

(FALSE)

3

1

"TG12367"

TRUE

(FALSE)

4

1

"HD44356"

FALSE

(FALSE)

5

2

"TG12367"

TRUE

TRUE

LEFT(FileData,
LENGTH(Match))

SubMatch =
Match

Result

FALSE

One mark for each underlined part

2

FUNCTION Extract(FileName:STRING, Match:STRING)
RETURNS INTEGER

One mark for each underlined part.
23
24
25
26
27
28
29
29
30
31
32

4

Marks

One mark for each column.

10
4(b)(ii)

Marks

WHILE NOT EOF(FileName) AND FileLine <= 100
READFILE FileName, FileData
SubMatch ← RIGHT(FileData, 10)
IF SubMatch = Match
THEN
Original[Counter] ← LEFT(FileData, 7)
Backup[Counter] ← RIGHT(FileData, 4)
Counter ← Counter + 1
ENDIF
FileLine ← FileLine + 1
ENDWHILE

Page 8 of 17

3

9608/23

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

October/November
2021

Question

Answer

4(c)

'Pseudocode' solution included here for development and clarification of mark
scheme.
Programming language example solutions appear in the Appendix.
PROCEDURE Encrypt()
DECLARE UnFileData : STRING // unencrypted
DECLARE EnFileData : STRING // encrypted
DECLARE Key, Counter : INTEGER
DECLARE EnChar : CHAR
OPENFILE "DATA.txt" FOR READ
OPENFILE "DATA-EN.txt" FOR APPEND
WHILE NOT EOF("DATA.txt")
READFILE "DATA.txt", UnFileData
Key ← STR_TO_NUM(MID(UnFileData, 9, 2))
EnFileData ← ""
FOR Counter ← 1 TO LENGTH(UnFileData)
EnChar ← CHR(Key + ASC(Mid(UnFileData, Counter,
1)))
EnFileData ← EnFileData & EnChar
ENDFOR
WRITEFILE "DATA-EN.txt", EnFileData
ENDWHILE
CLOSEFILE "DATA.txt"
CLOSEFILE "DATA-EN.txt"
ENDPROCEDURE
One mark for each of the following to Max 6
1
2
3
4
5
6
7

© UCLES 2021

Procedure heading (and ending)
Open and close the unencrypted file for READ and the encrypted file for
APPEND
Outer conditional loop until EOF() of the unencrypted file.
Extract the encryption key in the outer loop
Nested inner (count-controlled loop) that generates the ASCII value of the
unencrypted character
and generates the encrypted character using CHR function and
concatenate to form encrypted string
write the encrypted string to the data file in the outer loop

Page 9 of 17

Marks
6

9608/23

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
5(a)

October/November
2021

Answer
DECLARE GeoData : ARRAY[1:20000] OF STRING
DECLARE Review : ARRAY[1:20000] OF STRING
FUNCTION CheckReview(UserID : STRING) RETURNS STRING
DECLARE Status, ReviewString, RestGeo : STRING
DECLARE Index, GeoCounter : INTEGER
Status ← "LOCATION NOT FOUND" // default to not found
GeoCounter ← 1
ReviewString ← ""
RestGeo ← ""
Index ← 20000
// get the latest review
WHILE Index >= 1 AND ReviewString = ""
IF LEFT(Review[Index], 4) = UserID
THEN
ReviewString← Review[Index] //save review
// string for that user
ENDIF
Index ← Index - 1
ENDWHILE
IF LENGTH(ReviewString = 12 // check whether a review
// exists
THEN
Status ← "NO REVIEW"
ELSE
// get the geocode of the review
RestGeo ← MID(ReviewString, 6, 7)
ENDIF
// find this geocode in the array GeoData
WHILE Status = "LOCATION NOT FOUND" AND
GeoCounter <= 20000
IF GeoData[GeoCounter] = RestGeo
THEN
Status ← RIGHT(ReviewString,
LENGTH(ReviewString) – 13)
ENDIF
GeoCounter ← GeoCounter + 1
ENDWHILE
RETURN Status
ENDFUNCTION

© UCLES 2021

Page 10 of 17

Marks
8

9608/23

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
5(a)

Answer
One mark for each of the following to max 8
1
2
3
4
5
6
7
8
9

© UCLES 2021

October/November
2021

Declaration of local variables (but not UserID which must be parameter
or arrays)
Conditional loop iterating through the Review array finding the latest
review
... extract first 4 characters from Review array and compare with
parameter UserID
… if True, check if a review is included
… extract the restaurant’s GeoCode from the ReviewString
Conditional loop when match found with GeoCode and >= 20000 (or
break from FOR loop)
… selection statement to set Status to "LOCATION FOUND " inside the
loop
Return "NO REVIEW" and "LOCATION NOT FOUND"
Return the Users review

Page 11 of 17

Marks

9608/23

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

October/November
2021

Question

Answer

5(b)

'Pseudocode' solution included here for development and clarification of mark
scheme.
Programming language example solutions appear in the Appendix.
FUNCTION AddReview(UserID: STRING) RETURNS BOOLEAN
DECLARE Index : INTEGER
DECLARE ReviewEntry : STRING
DECLARE Result : BOOLEAN
Index ← 1
Result ← FALSE
// get the result of CheckReview()
ReviewEntry ← CheckReview(UserID)
IF ReviewEntry <> "NO REVIEW" AND __
ReviewEntry <> "LOCATION NOT FOUND"
THEN
// get the next free index of Accepted array
WHILE Index <= 20000 AND Result = FALSE
IF Accepted[Index] = ""
THEN
Accepted[Index] ← ReviewEntry
Result ← TRUE
ENDIF
Index ← Index + 1
ENDWHILE
ENDIF
RETURN Result
ENDFUNCTION
One mark for each of the following to Max 4
1
2
3
4
5

© UCLES 2021

Function header including parameter and return statement
Call to function CheckReview with UserID as parameter (and assign to
a variable)
If a valid review
… conditional loop with two conditions to find free index in Accepted
array until Counter = 20000
… store ReviewEntry in Accepted array

Page 12 of 17

Marks
4

9608/23

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
5(c)

October/November
2021

Answer
PROCEDURE BestRestaurants(SearchGeo : STRING)
DECLARE Index : INTEGER
DECLARE MatchFound : BOOLEAN
DECLARE Score : REAL // the extracted average score
DECLARE GeoCode : STRING // the extracted GeoCode
DECLARE ScoreLength: INTEGER // length of string to
// extract score
Index ← 1
MatchFound ← FALSE
//linear search of ReviewScores for GeoCode and Score
// > 8.0
WHILE Index <= 20000 AND MatchFound = FALSE
GeoCode ← LEFT(ReviewScores[Index, 1], 7)
ScoreLength ← LENGTH(ReviewScores[Index, 1]) – 8;
Score ← STRING_TO_NUM(RIGHT(ReviewScores[Index,
1],ScoreLength)
IF GeoCode = SearchGeo AND Score > 8.0
THEN
MatchFound ← TRUE
ELSE
Index ← Index + 1
ENDIF
ENDWHILE
// output the review if found
IF MatchFound = TRUE
THEN
OUTPUT SearchGeo & " " & ReviewScores[Index, 2]
ENDIF
ENDPROCEDURE
One mark for each of the following:
1
2
3
4
5

extract GeoCode from ReviewScores in any loop
extract the string representing Score from ReviewScores in any loop
convert extracted string to a numeric value following any attempt at MP2
in the loop
set MatchFound to TRUE if input parameter GeoCode is equal to
extracted GeoCode and extracted score > 8.0 in the loop
output parameter SearchGeo concatenated with its review text if
MatchFound is TRUE

*** End of Mark Scheme – example program code solutions follow ***

© UCLES 2021

Page 13 of 17

Marks
5

9608/23

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

October/November
2021

Program Code Example Solutions
Q4(c): Visual Basic
Sub Encrypt()
Dim UnFileData, EnFiledata As String
Dim Key, Counter As Integer
Dim EnChar As Char
Dim Sr As StreamReader = New StreamReader("DATA.txt")
Dim Sw As StreamWriter = New StreamWriter("DATA-EN.txt ", True)
'append
Do While Not Sr.EndOfStream
UnFileData = Sr.ReadLine()
Key = Convert.ToInt32(UnFileData.Substring(9, 2))
EnFiledata = ""
For Counter = 1 To UnFileData.Length
EnChar = Convert.ToChar(Key +
Convert.ToByte(UnFileData.Substring(Counter, 1)))
EnFiledata = EnFiledata & EnChar
Next
Sw.WriteLine(EnFiledata)
Loop
Sr.Close()
Sw.Close()
End Sub

© UCLES 2021

Page 14 of 17

9608/23

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

October/November
2021

Q4(c): Pascal
procedure Encrypt();
var
UnFileData : String;
EnFileData : String;
EnFileName : String;
Key, Counter : Integer;
EnChar : String;
DataFile : textfile;
DataEnFile : textfile;
begin
Assign(DataFile, 'DATA.txt ');
reset(DataFile);
EnFileName := 'DATA-EN.txt';
while not eof(DataFile) do
begin
readln(DataFile, UnFiledata);
Key := StrToInt(MidStr(UnFileData, 9, 2));
EnFileData := '';
for Counter := 1 to Length(UnFileData) do
begin
EnChar := Chr(Key+Ord(MidStr(UnFiledata, Counter, 1)[1]));
EnFileData := EnFileData + EnChar;
end;
Assign(DataEnFile, EnFileName);
append(DataEnFile);
writeln(DataEnFile, EnFileData);
end;
Close(DataFile);
Close(DataEnFile);
end;

© UCLES 2021

Page 15 of 17

9608/23

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Q4(c): Python
def Encrypt():
#DECLARE UnFileData : STRING
#DECLARE EnFileData : STRING
#DECLARE Key, Counter : INTEGER
#DECLARE EnChar : CHAR
UnFilehandle = open("DATA.txt", "r")
EnFilehandle = open("DATA-EN.txt", "a")
UnFileData = UnFileHandle.readline()
while UnFileData != "":
Key = UnFiledata[9:11]
EnFileData = ""
for Counter in range(1, len(UnFileData)):
EnChar = chr(Key + ord(UnFileData[Counter:1]))
EnFileData = EnFileData + EnChar
EnFilehandle.writeline(EnFileData)
UnFileData = UnFileHandle.readline()
UnFileHandle.close()
EnFileHandle.close()
Q5(b): Visual Basic
Function AddReview(UserID As String) As Boolean
Dim Index As Integer
Dim ReviewEntry As String
Dim Result As Boolean
Index = 1
Result = False
'get the result of CheckReview()
ReviewEntry = CheckReview(UserID)
If ReviewEntry <> "NO REVIEW" And
ReviewEntry <> "LOCATION NOT FOUND" Then
'get the next free index of Accepted array
Do While Index <= 20000 And Result = False
If Accepted(Index) = "" Then
Accepted(Index) = ReviewEntry
Result = True
End If
Index = Index + 1
Loop
End If
Return Result
End Function

© UCLES 2021

Page 16 of 17

October/November
2021

9608/23

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

October/November
2021

Q5(b): Pascal
function AddReview(UserID: string): boolean;
var
Index: integer;
ReviewEntry: string;
Result: boolean;
begin
Index := 1;
Result := False;
// get the result of CheckReview()
ReviewEntry := CheckReview(UserID);
if (ReviewEntry<>'NO REVIEW') and (ReviewEntry<>'LOCATION NOT FOUND')
then
begin
// get the next free index of Accepted array
while (Index <= 20000) and (Result=False) do
begin
if Accepted[Index] = '' then
begin
Accepted[Index] := ReviewEntry;
Result := True;
end;
Index := Index + 1;
end;
end;
AddReview := Result;
end;
Q5(b): Python
def AddReview(UserID):
#DECLARE Index : INTEGER
#DECLARE ReviewEntry : STRING
#DECLARE Result : BOOLEAN
Index = 1
Result = False
#get the result of CheckReview()
ReviewEntry = CheckReview(UserID)
if ReviewEntry != "NO REVIEW" and ReviewEntry != "LOCATION NOT FOUND":
#get the next free index of Accepted array
while Index <= 20000 and Result == False:
if Accepted[Index] == "":
Accepted[Index] = ReviewEntry
Result = True
Index += 1
return Result

© UCLES 2021

Page 17 of 17

Advertisement