Computer Science (9618) · May/June 2022 · Mark scheme 21
Cambridge Computer Science (9618) mark scheme for paper 21, May/June 2022 — 9618/21/M/J/22, file 9618_s22_ms_21.pdf.
Text of this paper
Cambridge International AS & A Level
COMPUTER SCIENCE
9618/21
Paper 21 Fundamental Problem Solving & Programming Skills
May/June 2022
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 May/June 2022 series for most
Cambridge IGCSE, Cambridge International A and AS Level and Cambridge Pre-U components, and some
Cambridge O Level components.
This document consists of 12 printed pages.
© UCLES 2022
[Turn over
9618/21
Cambridge International AS & A Level – Mark Scheme
PUBLISHED
May/June 2022
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 2022
Page 2 of 12
9618/21
Cambridge International AS & A Level – Mark Scheme
PUBLISHED
Question
1(a)
1(b)(i)
May/June 2022
Answer
Marks
An algorithm
1
Variable
Use of variable
Data type
Temp
Stores the average temperature
PetName
Stores the name of my pet
MyDOB
To calculate how many days until my
next birthday
LightOn
Stores state of light; light is only on or off
4
REAL
STRING
DATE
BOOLEAN
One mark for each data type
1(b)(ii)
2
One mark for variable name, and one for reason
Variable: Temp
Reason: Name does not indicate what the variable is used for
1(c)
Expression
Evaluation
INT((31 / 3) + 1)
4
11
MID(TO_UPPER("Version"), 4, 2)
"SI"
TRUE AND (NOT FALSE)
TRUE
NUM_TO_STR(27 MOD 3)
"0"
One mark per row
Question
2(a)
Answer
Marks
One mark per row
3
Answer
The number of different inputs
3
The number of different outputs
3
The single input value that could result in S4
© UCLES 2022
Page 3 of 12
Button-Y
9618/21
Cambridge International AS & A Level – Mark Scheme
PUBLISHED
Question
2(b)
May/June 2022
Answer
Marks
4
One mark per row
Example answer
Note: Accept other valid answers
Question
3(a)
Answer
Marks
One mark per description of appropriate sub-problem for given scenario.
3
Examples include:
3(b)
Allows the user to search for films being shown // input name of film they
want to see
Allows the user to search for available seats
Calculate cost of booking
Book a given number of seats for a particular screening
Function
Question
4(a)
1
Answer
Marks
One mark per row
2
Answer
© UCLES 2022
The value that has been on the stack for the longest time.
'H'
The memory location pointed to by TopOfStack if three
POP operations are performed.
206
Page 4 of 12
9618/21
Cambridge International AS & A Level – Mark Scheme
PUBLISHED
Question
May/June 2022
Answer
4(b)
Stack
Memory
location
Pointer
Marks
4
Value
200
201
'D'
202
'C'
203
'A'
204
'X'
205
'Z'
206
'N'
207
'P'
TopOfStack
One mark for:
1 TopOfStack pointing to 'D'
2 Value 'D' in 201
3 Values 'C' & 'A' in 202 and 203
4 Values 'X' to 'P' unchanged (204 to 207)
Question
5
Answer
3
4
5
6
7
8
© UCLES 2022
6
One mark per point to Max 6
1
2
Marks
Open file in read mode
Set up a conditional loop, repeating until the value is found or the EOF()
is reached
Read a line from the file in a loop
Extract Field 2
Description of how Field 2 could be extracted e.g. using substring
function and lengths of Field 1 and Field 2
Compare extracted field with search value
If search value found, extract Field 1and Field 3 and output them
Close the file after loop has finished
Page 5 of 12
9618/21
Cambridge International AS & A Level – Mark Scheme
PUBLISHED
Question
6(a)
Answer
DECLARE ThisInt, Count : INTEGER
Count 0
FOR ThisInt 100 TO 200
IF ThisInt MOD 10 = 7 THEN
OUTPUT ThisInt
Count Count + 1
ENDIF
NEXT ThisInt
OUTPUT Count
Mark as follows:
Declare loop variable and counter as integers, counter initialised
Loop 100 to 200, no step defined
Test value in a loop
Output selected value and incrementing a counter in a loop
Output the counter, following a reasonable attempt, after the loop
Alternative Solution:
DECLARE ThisInt, Count : INTEGER
Count 0
FOR ThisInt 107 TO 197 STEP 10
OUTPUT ThisInt
Count Count + 1
NEXT ThisInt
OUTPUT Count
Mark as follows:
1
2
3
4
5
© UCLES 2022
Marks
5
Simple Solution:
1
2
3
4
5
May/June 2022
Declare loop variable and counter as integers, , counter initialised
Loop (107 to 197)
STEP 10 or explicit increment if conditional loop used
Output each value and incrementing a counter in a loop
Output the counter, following a reasonable attempt, after the loop
Page 6 of 12
9618/21
Cambridge International AS & A Level – Mark Scheme
PUBLISHED
Question
6(b)
Answer
IF MySwitch = 1 THEN
ThisChar 'a'
ELSE
IF MySwitch = 2 THEN
ThisChar 'y'
ELSE
IF MySwitch = 3 THEN
ThisChar '7'
ELSE
ThisChar '*'
ENDIF
ENDIF
ENDIF
Mark as follows:
1.
2.
3.
4.
© UCLES 2022
ANY test of MySwitch = 1, 2 or 3
All three comparisons and corresponding assignments
OTHERWISE, or initial assignment of default value
Completely correct IF...THEN...ELSE...ENDIF syntax
Page 7 of 12
May/June 2022
Marks
4
9618/21
Cambridge International AS & A Level – Mark Scheme
PUBLISHED
Question
7(a)
May/June 2022
Answer
FUNCTION IsPalindrome(InString : STRING) RETURNS BOOLEAN
DECLARE IsPal : BOOLEAN
DECLARE Index, Num : INTEGER
DECLARE CharA, CharB : CHAR
IsPal TRUE
Index 1
Num INT(LENGTH(InString) / 2)
WHILE Index <= Num AND IsPal = TRUE
CharA MID(InString, Index, 1)
CharB MID(Instring, LENGTH(Instring) – Index + 1,
1)
IF UCASE(CharA) <> UCASE(CharB) THEN
IsPal FALSE // RETURN FALSE
ENDIF
Index Index + 1
ENDWHILE
RETURN IsPal // RETURN TRUE
ENDFUNCTION
Mark as follows:
1
2
3
4
5
6
7
© UCLES 2022
Functions header including parameter, ending and return type
Calculation of number of pairs to match (length or half length)
Loop for half or whole string
…Extracting characters to compare // create reverse string
Convert characters to same case
Check for mismatch of characters inside loop / test for mismatch after
loop for reversed string
Returning Boolean in both cases
Page 8 of 12
Marks
7
9618/21
Cambridge International AS & A Level – Mark Scheme
PUBLISHED
Question
7(b)
Answer
Label
Text
A
Set OutString to ""
B
Is Index > LENGTH(InString)?
C
Is MID(InString, Index, 1) = " "?
D
Set OutString to OutString & MID(InString, Index,
1)
E
Set Index to Index + 1
F
YES
G
NO
Mark for each of:
B
D
C
...F and G
Note: The mark for F and G is dependent on a reasonable attempt at C
© UCLES 2022
May/June 2022
Page 9 of 12
Marks
4
9618/21
Cambridge International AS & A Level – Mark Scheme
PUBLISHED
Question
8(a)
May/June 2022
Answer
FUNCTION RandomChar() RETURNS CHAR
DECLARE ThisRange : INTEGER
DECLARE ThisChar : CHAR
//First select the range
ThisRange INT(RAND(3)) + 1 // 1 to 3
CASE OF ThisRange
1: ThisChar CHR(INT(RAND(26) + 65)) // 65 to 90:
'A' to 'Z'
ThisChar LCASE(ThisChar)
// 'a' to 'z'
2: ThisChar CHR(INT(RAND(26) + 65)) // 65 to 90:
A to Z
3: ThisChar NUM_TO_STR(INT(RAND(10)) // '0' to '9'
ENDCASE
RETURN ThisChar
ENDFUNCTION
Mark as follows:
1
2
3
4
5
6
© UCLES 2022
Generation of any integer random number
Randomly decide which of the three ranges to select
Selection structure based on range
One alphanumeric character range correct
All alphanumeric character ranges correct
Return ThisChar, following a reasonable attempt to generate a
character in each range
Page 10 of 12
Marks
6
9618/21
Cambridge International AS & A Level – Mark Scheme
PUBLISHED
Question
8(b)
May/June 2022
Answer
FUNCTION FindPassword(Name: STRING) RETURNS STRING
DECLARE Index : INTEGER
DECLARE Password : STRING
Marks
7
Password ""
Index 1
WHILE Password = "" AND Index <= 500
IF Secret[Index, 1] = Name THEN
Password Decrypt(Secret[Index, 2])
ELSE
Index Index + 1
ENDIF
ENDWHILE
IF Password = "" THEN
OUTPUT "Domain name not found"
ENDIF
RETURN Password
ENDFUNCTION
Mark as follows:
1
2
3
4
5
6
7
8(c)
Declare all local variables used, attempted solution has to be reasonable
Conditional loop while not found and not end of array
Compare value of element in column 1 with parameter passed into
function
...and use Decrypt() with element in column 2 as parameter
…use the return value of Decrypt()
Output warning message if parameter not found
Return STRING value
One mark for the name, one for the description
Name:
Stub testing
3
Description:
A simple module is written to replace each of the modules.
The simple module will return an expected value // will output a message
to show they have been called
8(d)
Accept one example of a valid password to Max 2
One mark for each password example that breaks one of the rules due to:
Length too long // length too short
Invalid character
Incorrect grouping (including number of hyphens)
Duplicated characters
© UCLES 2022
Page 11 of 12
2
9618/21
Cambridge International AS & A Level – Mark Scheme
PUBLISHED
Question
8(e)
Answer
One mark for each part:
© UCLES 2022
May/June 2022
Marks
3
Generate a random integer divisible by 3
Split range into 1/3 and set as numeric
Else alphabetic character
Page 12 of 12