Cambridge International Advanced Subsidiary and Advanced Level
Cambridge International Advanced Subsidiary and Advanced Level
Write your centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
DC (ST) 171120/3
© UCLES 2019 [Turn over
2
(a) (i) This pseudocode lacks features that would make it easier to read and understand.
Feature 1 ...........................................................................................................................
Feature 2 ...........................................................................................................................
Feature 3 ...........................................................................................................................
[3]
(ii) Draw a program flowchart to represent the algorithm implemented in the pseudocode.
Variable declarations are not required in program flowcharts.
[5]
Complete the table by giving a suitable data type for each example value.
"NOT TRUE"
− 4.5
NOT FALSE
132
[4]
Refer to the Appendix on page 16–17 for the list of built-in functions and operators.
Expression Evaluates to
MID("sample", 3, 5)
NUM_TO_STRING(12.3 * 2)
INT(STRING_TO_NUM("53.4")) + 7
[4]
2 (a) A structure chart is often used in modular program design. One feature shown is the sequence
of module execution.
Feature 1 ..................................................................................................................................
...................................................................................................................................................
Feature 2 ..................................................................................................................................
...................................................................................................................................................
Feature 3 ..................................................................................................................................
...................................................................................................................................................
Feature 4 ..................................................................................................................................
...................................................................................................................................................
[4]
(b) Identify and describe one feature of an Integrated Development Environment (IDE) that can
help with program presentation.
Feature .....................................................................................................................................
Description ................................................................................................................................
...................................................................................................................................................
[2]
Method ......................................................................................................................................
Description ................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[2]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]
© UCLES 2019 9608/21/O/N/19 [Turn over
6
Study the pseudocode. Identify the relevant features in the following table.
Refer to the Appendix on pages 16–17 for the list of built-in functions and operators.
Feature Answer
[7]
4 A student is developing a program to count how many times each character of the alphabet (A to Z)
occurs in a given string. Upper case and lower case characters will be counted as the same. The
string may contain non-alphabetic characters, which should be ignored.
• check each character in the string to count how many times each alphabetic character occurs
• store the count for each alphabetic character in a 1D array
• output each count together with the corresponding character.
(a) The student has written a structured English description of the algorithm:
The student decides to apply a process to increase the level of detail given in step 4.
State the name of the process and use this process to write step 4 in more detail. Use
structured English for your answer.
Process .....................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[4]
You should assume the following lines of pseudocode have been written:
Declare any further variables you use. Do not implement the code as a subroutine.
Refer to the Appendix on pages 16–17 for the list of built-in functions and operators.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
Upper 0
Lower 0
Digit 0
Other 0
ENDFOR
ENDFUNCTION
(a) Describe the validation rules that are implemented by this pseudocode. Refer only to the
contents of the string and not to features of the pseudocode.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
© UCLES 2019 9608/21/O/N/19
11
(b) (i) Complete the trace table by dry running the function when it is called as follows:
Result CheckPassword("Jim+Smith*99")
[5]
(ii) State the value returned when the function is called using the expression shown. Justify
your answer.
Value .................................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
[2]
6 Account information for users of a library is held in one of two text files; UserListAtoM.txt and
UserListNtoZ.txt
The format of the data held in the two files is identical. Each line of the file is stored as a string that
contains an account number, name and telephone number separated by the asterisk character
('*') as follows:
"GB1234*Kevin Mapunga*07789123456"
The account number string may be six or nine characters in length and is unique for each
person. It is made up of alphabetic and numeric characters only.
An error has occurred and the same account number has been given to different users in the two
files. There is no duplication of account numbers within each individual file.
A program is to be written to search the two files and to identify duplicate entries. The account
number of any duplicate found is to be written to an array, Duplicates, which is a 1D array of
100 elements of data type STRING.
The program is to be implemented as several modules. The outline description of three of these is
as follows:
ClearArray()
• Initialise the global array Duplicates. Set all elements to the
empty string.
• Read each line from the file UserListAtoM.txt
• Check whether the account number appears in file
UserListNtoZ.txt using SearchFileNtoZ()
FindDuplicates() • If the account number does appear then add the account
number to the array.
• Output an error message and exit the module if there are more
duplicates than can be written to the array.
• Search for a given account number in file UserListNtoZ.txt
SearchFileNtoZ()
• If found, return TRUE, otherwise return FALSE
(a) State one reason for storing data in a file rather than in an array.
...................................................................................................................................................
............................................................................................................................................. [1]
Visual Basic and Pascal: You should include the declaration statements for variables.
Python: You should show a comment statement for each variable used with its data type.
Program code
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
© UCLES 2019 9608/21/O/N/19 [Turn over
14
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [8]
(d) ClearArray() is to be modified to make it general purpose. It will be used to initialise any
1D array of data type STRING to any value.
1. The array
2. The number of elements
3. The initialisation string
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [3]
(ii) Write program code for a statement that calls the modified ClearArray() procedure
to clear the array Duplicates to "Empty".
Program code
...........................................................................................................................................
...........................................................................................................................................
[2]
Appendix
Built-in functions (pseudocode)
Each function returns an error if the function call is not properly formed.
Operators (pseudocode)
Operator Description
Concatenates (joins) two strings
&
Example: "Summer" & " " & "Pudding" produces "Summer Pudding"
Performs a logical AND on two Boolean values
AND
Example: TRUE AND FALSE produces FALSE
Performs a logical OR on two Boolean values
OR
Example: TRUE OR FALSE produces TRUE
BLANK PAGE
BLANK PAGE
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 the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of
Cambridge Local Examinations Syndicate (UCLES), which itself is a department of the University of Cambridge.