June 2022 (v2) QP
June 2022 (v2) QP
June 2022 (v2) QP
2 hours
INSTRUCTIONS
● Answer all questions.
● Use a black or dark blue pen.
● Write your name, centre number and candidate number in the boxes at the top of the page.
● Write your answer to each question in the space provided.
● Do not use an erasable pen or correction fluid.
● Do not write on any bar codes.
● You may use an HB pencil for any diagrams, graphs or rough working.
● Calculators must not be used in this paper.
INFORMATION
● The total mark for this paper is 75.
● The number of marks for each question or part question is shown in brackets [ ].
● No marks will be awarded for using brand names of software packages or hardware.
● The insert contains all the resources referred to in the questions.
DC (KN/SW) 303772/3
© UCLES 2022 [Turn over
PMT
Refer to the insert for the list of pseudocode functions and operators.
Give the technical term for the position at which the program stops.
............................................................................................................................................. [1]
(b) The following table lists some activities from the program development life cycle.
Complete the table by writing the life cycle stage for each activity.
State two other pieces of information that the identifier table should contain.
1 ................................................................................................................................................
2 ................................................................................................................................................
[2]
(d) The pseudocode statements in the following table may contain errors.
State the error in each case or write 'NO ERROR' if the statement contains no error.
You can assume that none of the variables referenced are of an incorrect type.
Statement Error
Code LCASE("Electrical")
Result IS_NUM(-27.3)
[4]
START
END
[4]
3 (a) The module headers for five modules in a program are defined in pseudocode as follows:
(i) Complete the structure chart to include the information given about the six modules.
Do not label the parameters and do not write the module names.
B C D
E F
[3]
(ii) Complete the table using the information in part 3(a) by writing each module name to
replace the labels A to F.
F
[3]
(b) The structure chart represents part of a complex problem. The process of decomposition is
used to break down the complex problem into sub-problems.
1 ................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
...................................................................................................................................................
3 ................................................................................................................................................
...................................................................................................................................................
[3]
Note:
• Use local variables LineX, LineY and LineZ to store the three lines from the file.
• You may assume the file exists and contains at least three lines.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
(b) The algorithm in part (a) is to be amended. The calling program will pass the number of lines
to be output as well as the name of the text file.
It can be assumed that the file contains at least the number of lines passed.
1 ................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
3 ................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[3]
5 Study the following pseudocode. Line numbers are for reference only.
10 PROCEDURE Encode()
11 DECLARE CountA, CountB, ThisNum : INTEGER
12 DECLARE ThisChar : CHAR
13 DECLARE Flag : BOOLEAN
14 CountA 0
15 CountB 10
16 Flag TRUE
17 INPUT ThisNum
18 WHILE ThisNum <> 0
19 ThisChar LEFT(NUM_TO_STR(ThisNum), 1)
20 IF Flag = TRUE THEN
21 CASE OF ThisChar
22 '1' : CountA CountA + 1
23 '2' : IF CountB < 10 THEN
24 CountA CountA + 1
25 ENDIF
26 '3' : CountB CountB - 1
27 '4' : CountB CountB - 1
28 Flag FALSE
29 OTHERWISE : OUTPUT "Ignored"
30 ENDCASE
31 ELSE
32 IF CountA > 2 THEN
33 Flag NOT Flag
34 OUTPUT "Flip"
35 ELSE
36 CountA 4
37 ENDIF
38 ENDIF
39 INPUT ThisNum
40 ENDWHILE
41 OUTPUT CountA
42 ENDPROCEDURE
Identify the type of loop and state the condition that ends the loop.
Type ..........................................................................................................................................
Condition ..................................................................................................................................
...................................................................................................................................................
[2]
© UCLES 2022 9618/22/M/J/22
PMT
(b) Complete the trace table below by dry running the procedure Encode() when the following
values are input:
12, 24, 57, 43, 56, 22, 31, 32, 47, 99, 0
0 10 TRUE
[6]
(c) Procedure Encode() is part of a modular program. Integration testing is to be carried out on
the program.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]
10
For example:
"12,13,451,22"
Assume that:
• the comma character ',' is used as a separator
• the string contains only the characters '0' to '9' and the comma character ','.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
11
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
ENDPROCEDURE [7]
12
7 A programming language has string functions equivalent to those given in the insert.
The language includes a LEFT() and a RIGHT() function, but it does not have a MID() function.
(a) Write pseudocode for an algorithm to implement your own version of the MID() function
which will operate in the same way as that shown in the insert.
Do not use the MID() function given in the insert, but you may use any of the other functions.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
(b) The values passed to your MID() function in part (a) need to be validated.
State two checks that could be applied to the values passed to the function.
1 ................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
...................................................................................................................................................
[2]
13
BLANK PAGE
14
8 A program allows a user to save passwords used to log in to websites. A stored password is then
inserted automatically when the user logs in to the corresponding website.
A global 2D array Secret of type STRING stores the passwords together with the website domain
name where they are used. Secret contains 1000 elements organised as 500 rows by 2 columns.
Unused elements contain the empty string (""). These may occur anywhere in the array.
Note:
• For security, the passwords are stored in an encrypted form, shown as "" in the
example.
• The passwords cannot be used without being decrypted.
• You may assume that the encrypted form of a password will NOT be an empty string.
Module Description
• Takes two parameters:
○ a string
○ a character
Exists()
• Performs a case-sensitive search for the character in the string
• Returns TRUE if the character occurs in the string, otherwise
returns FALSE
• Takes a password as a parameter of type string
Encrypt()
• Returns the encrypted form of the password as a string
• Takes an encrypted password as a parameter of type string
Decrypt()
• Returns the decrypted form of the password as a string
15
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [5]
16
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
17
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [8]
18
(c) A password has a fixed format, consisting of three groups of four alphanumeric characters,
separated by the hyphen character '-'.
An algorithm is needed for a new function GeneratePassword(), which will generate and
return a password in this format.
Module Description
• Takes two parameters:
○ a string
○ a character
Exists() • Performs a case-sensitive search for the character in the
string
• Returns TRUE if the character occurs in the string, otherwise
returns FALSE
• Generates a single random character from within one of the
following ranges:
○ 'a' to 'z'
RandomChar()
○ 'A' to 'Z'
○ '0' to '9'
• Returns the character
19
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
20
BLANK PAGE
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Local Examinations Syndicate (UCLES), which is a department of the University of Cambridge.