Computer Science (9618) · May/June 2022 · Mark scheme 22

Cambridge Computer Science (9618) mark scheme for paper 22, May/June 2022 — 9618/22/M/J/22, file 9618_s22_ms_22.pdf.

Advertisement
Loading the paper…
Text of this paper

Cambridge International AS & A Level
SUBJECT

9618/22

Paper 22 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 14 printed pages.
© UCLES 2022

[Turn over

9618/22

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 14

9618/22

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
1(a)

May/June 2022

Answer

Marks

Correct answer only:

1

Breakpoint
1(b)

One mark per row

4
Activity

1(c)

An identifier table is produced.

Design

Syntax errors can occur.

Coding

The developer discusses the program requirements with the
customer.

Analysis

A trace table is produced.

Testing

One mark per bullet point to Max 2





1(d)

Life cycle stage

2

A description of what the identifier is used for / the purpose of the identifier
The data type of the identifier
The number of elements of an array // the length of a string
An example data value
Value of any constants used
The scope of the variable (local or global)

One mark per row

4

Statement

© UCLES 2022

Error

Status  TRUE AND FALSE

NO ERROR

IF LENGTH("Password") <
"10" THEN

"10" shouldn’t be a string // must be an
integer

Code 
LCASE("Electrical")

Parameter must be a char // cannot be a
string
Alternative:
LCASE should be TO_LOWER

Result  IS_NUM(-27.3)

Parameter must be a string / char //
cannot be a number

Page 3 of 14

9618/22

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question

May/June 2022

Answer

Marks
4

2

One mark per point:
1
2
3
4

© UCLES 2022

Initialise Count before loop AND Input NextNum in a loop
Loop until NextNum < 0 AND OUTPUT statement including Count plus a
message
Use of IsPrime(NextNum)as a function (must return a value)
Check return value AND increment Count if appropriate

Page 4 of 14

9618/22

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
3(a)(i)

May/June 2022

Answer
One mark per red annotation

3(a)(ii)

Label

3

3

Module name

A

Head

B

Mod_W

C

Mod_X

D

Mod_V

E

Mod-Z

F

Mod_Y

Marks

Marks as follows:
 Two rows correct – one mark
 Four rows correct – two marks
 All rows correct – three marks
3(b)

One mark per point:
 Breaking a complex problem down makes it easier to understand / solve //
smaller problems are easier to understand / solve
 Smaller problems are easier to program / test / maintain
 Sub-problems can be given to different teams / programmers with different
expertise // can be solved separately

© UCLES 2022

Page 5 of 14

3

9618/22

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
4(a)

May/June 2022

Answer

Marks

PROCEDURE LastLines(ThisFile : STRING)
DECLARE ThisLine, LineX, LineY, LineZ : STRING
OPENFILE ThisFile FOR READ
LineY  ""
LineZ  ""
WHILE NOT EOF(ThisFile)
READFILE Thisfile, ThisLine
LineX  LineY
LineY  LineZ
LineZ  ThisLine
ENDWHILE

// read a line

CLOSEFILE ThisFile
OUTPUT LineX
OUTPUT LineY
OUTPUT LineZ
ENDPROCEDURE
Marks as follows to Max 6:
1
2
3
4
5
6
7

© UCLES 2022

Procedure heading (including parameter) and ending
Declaration of local variables for three lines AND File OPEN in READ mode AND
CLOSE
Loop until EOF(ThisFile)
Read line from file... in a loop
Attempt at a shuffle… in a loop
Correctly shuffle LineX, LineY and LineZ in a loop
OUTPUT the three lines in correct sequence, following reasonable attempt

Page 6 of 14

6

9618/22

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
4(a)

May/June 2022

Answer

Marks

Alternative (using two loops):
PROCEDURE LastLines(ThisFile : STRING)
DECLARE ThisLine, LineX, LineY, LineZ : STRING
DECLARE Count, Count2 : INTEGER
Count  0
OPENFILE ThisFile FOR READ
WHILE NOT EOF(ThisFile)
READFILE Thisfile, ThisLine
Count  Count + 1
ENDWHILE

// read a line

CLOSEFILE ThisFile
OPENFILE ThisFile FOR READ
FOR Count2  1 TO Count - 3
READFILE Thisfile, ThisLine
NEXT Count2

// read a line

READFILE Thisfile, LineX
READFILE Thisfile, LineY
READFILE Thisfile, LineZ
OUTPUT LineX
OUTPUT LineY
OUTPUT LineZ
CLOSEFILE ThisFile
ENDPROCEDURE
Marks as follows to Max 6:
1
2
3
4
5

Procedure heading (including parameter) and ending
Declaration of local variables for three lines AND (at least one) File OPEN in
READ mode AND CLOSE
Loop until EOF(ThisFile)
Read line from file and increment Count in a loop
Two separate loops, closing and re-opening the file between loops

6

Read Count - 3 lines from the file

7

OUTPUT the last three lines in correct sequence, following reasonable attempt

© UCLES 2022

Page 7 of 14

9618/22

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
4(b)

May/June 2022

Answer

3

One mark per point to Max 3:
1
2
3
4
5

Change the procedure header to include a (numeric) parameter (as well as the
filename)
Replace LineX, Y and Z with an array
Amend shuffle mechanism
Use new parameter to determine first line to output
Output the lines in a loop

Alternative 'two loop' solution to Max 3:
1 Change the procedure header to include a numeric parameter (as well as the
filename)
2 A loop to count the total number of lines in the file
3 Ref use of single variable rather than LineX, LineY and LineZ
4 Close and re-open the file
5 Use the new parameter value to determine first line to output
6 Output the lines in a loop

© UCLES 2022

Marks

Page 8 of 14

9618/22

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
5(a)

May/June 2022

Answer

Marks

One mark for type and one mark for condition:
Independent marks

2

Type: pre-condition
Condition: when the value of ThisNum / the input value is equal to zero
6

5(b)
ThisNum

ThisChar

CountA

CountB

Flag

0

10

TRUE

12

'1'

24

'2'

57

'5'

43

'4'

56

'5'

22

'2'

31

'3'

8

32

'3'

7

47

'4'

6

99

'9'

OUTPUT

1

"Ignored"
9

FALSE

4
TRUE

"Flip"

FALSE
TRUE

0

"Flip"
4

Marks as follows:
One mark per outlined group
If no marks per group then mark by columns (columns 3 to 6) for max 4
5(c)

One mark per point:
 Modules that have already been tested individually
 are combined into a single (sub) program which is then tested as a whole

© UCLES 2022

Page 9 of 14

2

9618/22

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
6

May/June 2022

Answer
PROCEDURE Parse(InString : STRING)
DECLARE Count, Total, Index : INTEGER
DECLARE Average : REAL
DECLARE NumString : STRING
DECLARE ThisChar : CHAR
CONSTANT COMMA = ','
Count  0
Total  0
NumString  ""
FOR Index  1 to LENGTH(InString)
ThisChar  MID(InString, Index, 1)
IF ThisChar = COMMA THEN
Total  Total + STR_TO_NUM(NumString)
Count  Count + 1
NumString  ""
ELSE
NumString  NumString & ThisChar // build the number
string
ENDIF
NEXT Index
// now process the final number
Total  Total + STR_TO_NUM(NumString)
Count  Count + 1
Average  Total / Count
OUTPUT "The total was ", Total, " and the average was ",
Average
ENDPROCEDURE
Marks as follows:
1 Declare and initialise Count, Total and NumString
2 Loop for number of characters in InString
3
Extract a character and test for comma in a loop
4
If comma, convert NumString to integer and update Total and Count
5
and reset NumString
6
Otherwise append character to NumString
7 Calculate average AND final output statement(s) outside the loop

© UCLES 2022

Page 10 of 14

Marks
7

9618/22

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
7(a)

Answer
FUNCTION MID(InString : STRING, Start, Num : INTEGER)
RETURNS STRING
DECLARE MidString : STRING
DECLARE InStringLen : INTEGER

May/June 2022

Marks
4

InStringLen  LENGTH(InString)
// solution for RIGHT() then LEFT()
MidString  RIGHT(InString, InStringLen – Start + 1)
MidString  LEFT(MidString, Num)
// alternative solution for LEFT() then RIGHT()
MidString  LEFT(InString, Start + Num - 1)
MidString  RIGHT(MidString, Num)
RETURN MidString
ENDFUNCTION
Marks as follows:
1 Function heading and ending including parameters and return type
2 Correct use of one substring functions
3 Correct use of both substring functions (in correct sequence)
4 Return substring after a reasonable attempt
7(b)

One mark per point

2

Check that:
 Start and/or Num are >= 1 // positive
 Length of InString is "sufficient" for required operation

© UCLES 2022

Page 11 of 14

9618/22

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
8(a)

Answer
FUNCTION Exists(ThisString : STRING, Search : CHAR)
RETURNS BOOLEAN
DECLARE Found : BOOLEAN
DECLARE Index : INTEGER
Found  FALSE
Index  1
WHILE Found = FALSE AND Index <= LENGTH(ThisString)
IF MID(ThisString, Index, 1) = Search THEN
Found  TRUE
ELSE
Index  Index + 1
ENDIF
ENDWHILE
RETURN Found
ENDFUNCTION
Marks as follows (Conditional loop solution):
1 Conditional loop while character not found and not end of string
2
Extract a char in a loop
3
Compare with parameter without case conversion in a loop
4
If match found, set termination logic in a loop
5 Return BOOLEAN value
ALTERNATIVE (Using Count-controlled loop):
FOR Index  1 TO LENGTH(ThisString)
IF MID(ThisString, Index, 1) = Search THEN
RETURN TRUE
ENDIF
NEXT Index
RETURN FALSE
Marks as follows (Count-controlled loop variant):
1 Loop for length of ThisString (allow from 0 or 1)
2
Extract a char in a loop
3
Compare with parameter without case conversion in a loop
4
If match found, immediate RETURN of TRUE
5 Return FALSE after the loop // Return Boolean if no immediate RETURN

© UCLES 2022

Page 12 of 14

May/June 2022

Marks
5

9618/22

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
8(b)

May/June 2022

Answer
PROCEDURE
DECLARE
DECLARE
DECLARE

SearchDuplicates()
IndexA, IndexB : INTEGER
ThisPassword, ThisValue : STRING
Duplicates : BOOLEAN

Duplicates  FALSE
IndexA  1
WHILE Duplicates = FALSE AND IndexA < 500
ThisValue  Secret[IndexA, 2]
IF ThisValue <> "" THEN
ThisPassword  Decrypt(ThisValue)
FOR IndexB  IndexA + 1 TO 500 //
IF Secret[IndexB, 2] <> "" THEN
IF Decrypt(Secret[IndexB, 2]) = ThisPassword
THEN
OUTPUT "Password for " & Secret[IndexA, 1] &
"also used for " & Secret[IndexB, 1]
Duplicates  TRUE
ENDIF
ENDIF
NEXT IndexB
ENDIF
IndexA  IndexA + 1
ENDWHILE
IF Duplicates = FALSE THEN
OUTPUT "No duplicate passwords found"
ENDIF
ENDPROCEDURE
Marks as follows to Max 8:
1.
2.
3.
4.
5.
6.
7.
8.
9.

© UCLES 2022

(Any) conditional loop...
... from 1 to 499 while (attempt at) no duplicate
Skip unused password
Use Decrypt() and assign return value to ThisPassword
Inner loop from outer loop index + 1 to 500 searching for duplicates
Compare ThisPassword with subsequent passwords (after use of
Decrypt())
If match found, set outer loop termination
and attempt an Output message giving duplicate
Output 'No duplicate passwords found' message if no duplicates found after the
loop

Page 13 of 14

Marks
8

9618/22

Cambridge International AS & A Level – Mark Scheme
PUBLISHED

Question
8(c)

May/June 2022

Answer
One mark for each point that is referenced:
1
2
3
4
5
6

© UCLES 2022

Initialise password to empty string at the start and return (attempted) password
at the end of the function
Two loops to generate 3 groups of 4 characters // One loop to generate 12 / 14
characters
Use of RandomChar()to generate a character in a loop
Reject character if Exists()returns TRUE, otherwise form string in a loop
(Attempt to) use hyphens to link three groups
Three groups of four characters generated correctly with hyphens and without
duplication (completely working algorithm)

Page 14 of 14

Marks
6

Advertisement