Practical Papers CS
Practical Papers CS
* 0 9 1 0 1 4 3 9 3 6 *
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 (PQ) 214717
© UCLES 2021 [Turn over
2
Refer to the insert for the list of pseudocode functions and operators.
1 (a) A program is being developed to help manage the membership of a football club.
Example
Explanation Variable name Data type
value
(b) Each pseudocode statement in the following table may contain an error due to the incorrect
use of the function or operator.
Describe 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
Result 2 & 4
SubString MID("pseudocode", 4, 1)
IF x = 3 OR 4 THEN
[5]
(c) The following data items need to be stored for each student in a group:
Structure ...................................................................................................................................
Justification ...............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[3]
Draw a structure chart to show the relationship between the four modules and the parameters
passed between them.
[5]
© UCLES 2021 9618/21/M/J/21
5
...................................................................................................................................................
............................................................................................................................................. [2]
[6]
© UCLES 2021 9618/21/M/J/21
7
BLANK PAGE
3 (a) A concert venue uses a program to calculate admission prices and store information about
ticket sales.
A number of arrays are used to store data. The computer is switched off overnight and data
has to be input again at the start of each day before any tickets can be sold. This process is
very time consuming.
(i) Explain how the program could use text files to speed up the process.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
(ii) State the characteristic of text files that allow them to be used as explained in part (a)(i).
...........................................................................................................................................
..................................................................................................................................... [1]
(iii) Information about ticket sales will be stored as a booking. The booking requires the
following data:
Suggest how data relating to each booking may be stored in a text file.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [5]
4 Study the following pseudocode. Line numbers are for reference only.
(a) Complete the trace table below by dry running the function when it is called as follows:
Result Convert("∇in∇a∇∇Cup")
Note: The symbol '∇' has been used to represent a space character.
Use this symbol for any space characters in the trace table.
"∇in∇a∇∇Cup"
[5]
...................................................................................................................................................
Justification ...............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[2]
Change 1: Convert to lower case any character that is not the first character after a space.
Change 2: Replace multiple spaces with a single space.
...........................................................................................................................................
.......................................................................................................................................[1]
Write the number of the line to be moved and state its new position.
...........................................................................................................................................
[2]
BLANK PAGE
5 A global 2D array Result of type INTEGER is used to store a list of exam candidate numbers
together with their marks. The array contains 2000 elements, organised as 1000 rows and
2 columns.
Column 1 contains the candidate number and column 2 contains the mark for the corresponding
candidate. All elements contain valid exam result data.
A procedure Sort() is needed to sort Result into ascending order of mark using an efficient
bubble sort algorithm.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [8]
6 The following diagram represents an Abstract Data Type (ADT) for a linked list.
A C D E Ø
(a) Explain how a node containing data value B is added to the list in alphabetic sequence.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
(b) Describe how the linked list in part (a) may be implemented using variables and arrays.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]
BLANK PAGE
7 A program is needed to take a string containing a full name and produce a new string of initials.
Some words in the full name will be ignored. For example, "the", "and", "of", "for" and "to" may all
be ignored.
For example:
The programmer has decided to use a global variable FNString of type STRING to store the full
name.
It is assumed that:
• words in the full name string are separated by a single space character
• space characters will not occur at the beginning or the end of the full name string
• the full name string contains at least one word.
Module Description
• Called with an INTEGER as a parameter, representing the number of a
word in FNString.
GetStart()
• Returns the character start position of that word in FNString or
returns –1 if that word does not exist
• For example: if FNString contains the string "hot and cold",
GetStart(3) returns 9
• Called with a parameter representing the position of the first character
of a word in FNString
GetWord() • Returns the word from FNString
• For example: if FNString contains the string "hot and cold",
GetWord(9) returns "cold"
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
(b) The programmer has decided to use a global ten-element 1D array IgnoreList of type
STRING to store the ignored words. Unused elements contain the empty string ("") and may
occur anywhere in the array.
Module Description
• Called with a parameter representing a word
• Stores the word in an unused element of the IgnoreList array
AddWord() and returns TRUE
• Returns FALSE if the array was already full or if the word was
already in the array
Write a detailed description of the algorithm for AddWord(). Do not include pseudocode
statements in your answer.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
Module Description
• Called with a parameter representing the position of the first
character of a word in FNString
GetWord() • Returns the word from FNString
• For example: if FNString contains the string "hot and cold",
GetWord(9) returns "cold"
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [5]
© UCLES 2021 9618/21/M/J/21
22
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.
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 (MB/FC) 200588/5
© UCLES 2021 [Turn over
2
Refer to the insert for the list of pseudocode functions and operators.
1 (a) (i) Complete the following table by giving the appropriate data type in each case.
(ii) Evaluate each expression in the following table by using the initial data values shown in
part (a)(i).
Expression Evaluates to
Modified OR Index > 100
LENGTH("Student: " & Name)
INT(Index + 2.9)
MID(Name, 1, 3)
[4]
(b) Each pseudocode statement in the following table contains an example of selection,
assignment or iteration.
Put one tick (‘✓’) in the appropriate column for each statement.
X S2
S1
Answer
The number of transitions that result in a different state
The number of transitions with associated outputs
The label that should replace ‘X’
The final or halting state
[4]
Registered users may borrow books from the library for a period of time.
(i) State three items of data that must be stored for each loan.
1 ........................................................................................................................................
2 ........................................................................................................................................
3 ........................................................................................................................................
[2]
(ii) State one item of data that will be required in the library system but does not need to be
stored for each loan.
..................................................................................................................................... [1]
(iii) One operation that manipulates the data stored for each loan, would produce a list of all
overdue books.
Operation 1 .......................................................................................................................
...........................................................................................................................................
Operation 2 .......................................................................................................................
...........................................................................................................................................
[2]
A B
Dolphin Cat Fish Elk
............................................................................................................................................. [1]
(b) Give the technical term for the item labelled A in the diagram.
............................................................................................................................................. [1]
(c) Give the technical term for the item labelled B in the diagram.
Term ..........................................................................................................................................
Meaning ....................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[2]
(d) Complete the diagram to show the ADT after the data has been sorted in alphabetical order.
[2]
4 A teacher uses a paper-based system to store marks for a class test. The teacher requires a
program to assign grades based on these results.
The program will output the grades together with the average mark.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [6]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [6]
(ii) The student decides to modify the algorithm so that each element of the array will contain
a unique value.
Describe the changes that the student needs to make to the algorithm.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [3]
Answer
...........................................................................................................................................
..................................................................................................................................... [2]
BLANK PAGE
The string may contain both upper and lower case characters.
Each count value will be stored in a unique element of a global 1D array CharCount of type
INTEGER. The array will contain six elements.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [8]
7 A procedure, FormatName():
• is called with a string containing words and spaces as its parameter. In this context, a word is
any sequence of characters that does not contain a space character.
• creates a new formatted string from this string with the following requirements:
1. Any leading spaces removed (spaces before the first word).
2. Any trailing spaces removed (spaces after the last word).
3. Any multiple spaces between words converted to a single space.
4. All characters converted to lower case.
The FormatName() procedure has been written in a programming language and is to be tested
using the black-box method.
(a) Give a test string that could be used to show that all four formatting requirements have been
applied correctly.
............................................................................................................................................. [3]
(b) The FormatName() procedure should assign a value to the global variable FString.
There is a fault in the program, which means that the assignment does not always take place.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]
8 A program is needed to take a string containing a full name and to produce a new string of initials.
Some words in the full name will be ignored. For example, “the”, “and”, “of”, “for” and “to” may all
be ignored.
For example:
• a ten element 1D array IgnoreList of type STRING to store the ignored words
• a string FNString to store the full name string.
Assume that:
• each alphabetic character in the full name string may be either upper or lower case
• the full name string contains at least one word.
Module Description
• Called with an INTEGER as its parameter, representing the number of
a word in FNString
GetStart() • Returns the character start position of that word in FNString or
returns -1 if that word does not exist
• For example: GetStart(3) applied to "hot and cold" returns 9
• Called with the position of the first character of a word in FNString
as its parameter
GetWord() • Returns the word from FNString
• For example: if FNString contains the string "hot and cold",
GetWord(9) returns "cold"
• Called with a STRING parameter representing a word
IgnoreWord() • Searches for the word in the IgnoreList array
• Returns TRUE if the word is found, otherwise returns FALSE
• Processes the sequence of words in the full name one word at a time
GetInitials()
• Calls GetStart(), GetWord() and IgnoreWord() to process
each word to form the new string
• Outputs the new string
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [5]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [8]
© UCLES 2021 9618/22/M/J/21
15
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.
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 (PQ/FC) 200587/4
© UCLES 2021 [Turn over
2
Refer to the insert for the list of pseudocode functions and operators.
1 (a) A program is being developed to help manage the membership of a football club.
Example
Explanation Variable name Data type
value
(b) Each pseudocode statement in the following table may contain an error due to the incorrect
use of the function or operator.
Describe 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
Result 2 & 4
SubString MID("pseudocode", 4, 1)
IF x = 3 OR 4 THEN
[5]
(c) The following data items need to be stored for each student in a group:
Structure ...................................................................................................................................
Justification ...............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[3]
Draw a structure chart to show the relationship between the four modules and the parameters
passed between them.
[5]
© UCLES 2021 9618/23/M/J/21
5
...................................................................................................................................................
............................................................................................................................................. [2]
[6]
© UCLES 2021 9618/23/M/J/21
7
BLANK PAGE
3 (a) A concert venue uses a program to calculate admission prices and store information about
ticket sales.
A number of arrays are used to store data. The computer is switched off overnight and data
has to be input again at the start of each day before any tickets can be sold. This process is
very time consuming.
(i) Explain how the program could use text files to speed up the process.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
(ii) State the characteristic of text files that allow them to be used as explained in part (a)(i).
...........................................................................................................................................
..................................................................................................................................... [1]
(iii) Information about ticket sales will be stored as a booking. The booking requires the
following data:
Suggest how data relating to each booking may be stored in a text file.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [5]
4 Study the following pseudocode. Line numbers are for reference only.
(a) Complete the trace table below by dry running the function when it is called as follows:
Result Convert("∇in∇a∇∇Cup")
Note: The symbol '∇' has been used to represent a space character.
Use this symbol for any space characters in the trace table.
"∇in∇a∇∇Cup"
[5]
...................................................................................................................................................
Justification ...............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[2]
Change 1: Convert to lower case any character that is not the first character after a space.
Change 2: Replace multiple spaces with a single space.
...........................................................................................................................................
.......................................................................................................................................[1]
Write the number of the line to be moved and state its new position.
...........................................................................................................................................
[2]
BLANK PAGE
5 A global 2D array Result of type INTEGER is used to store a list of exam candidate numbers
together with their marks. The array contains 2000 elements, organised as 1000 rows and
2 columns.
Column 1 contains the candidate number and column 2 contains the mark for the corresponding
candidate. All elements contain valid exam result data.
A procedure Sort() is needed to sort Result into ascending order of mark using an efficient
bubble sort algorithm.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [8]
6 The following diagram represents an Abstract Data Type (ADT) for a linked list.
A C D E Ø
(a) Explain how a node containing data value B is added to the list in alphabetic sequence.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
(b) Describe how the linked list in part (a) may be implemented using variables and arrays.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]
BLANK PAGE
7 A program is needed to take a string containing a full name and produce a new string of initials.
Some words in the full name will be ignored. For example, "the", "and", "of", "for" and "to" may all
be ignored.
For example:
The programmer has decided to use a global variable FNString of type STRING to store the full
name.
It is assumed that:
• words in the full name string are separated by a single space character
• space characters will not occur at the beginning or the end of the full name string
• the full name string contains at least one word.
Module Description
• Called with an INTEGER as a parameter, representing the number of a
word in FNString.
GetStart()
• Returns the character start position of that word in FNString or
returns –1 if that word does not exist
• For example: if FNString contains the string "hot and cold",
GetStart(3) returns 9
• Called with a parameter representing the position of the first character
of a word in FNString
GetWord() • Returns the word from FNString
• For example: if FNString contains the string "hot and cold",
GetWord(9) returns "cold"
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
(b) The programmer has decided to use a global ten-element 1D array IgnoreList of type
STRING to store the ignored words. Unused elements contain the empty string ("") and may
occur anywhere in the array.
Module Description
• Called with a parameter representing a word
• Stores the word in an unused element of the IgnoreList array
AddWord() and returns TRUE
• Returns FALSE if the array was already full or if the word was
already in the array
Write a detailed description of the algorithm for AddWord(). Do not include pseudocode
statements in your answer.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
Module Description
• Called with a parameter representing the position of the first
character of a word in FNString
GetWord() • Returns the word from FNString
• For example: if FNString contains the string "hot and cold",
GetWord(9) returns "cold"
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [5]
© UCLES 2021 9618/23/M/J/21
22
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.
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 (PQ) 222284
© UCLES 2021 [Turn over
2
Refer to the insert for the list of pseudocode functions and operators.
1 Sylvia is testing a program that has been written by her colleague. Her colleague tells her that the
program does not contain any syntax errors.
(a) (i) State what her colleague means by “does not contain any syntax errors”.
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [1]
(ii) Identify and describe one other type of error that the program may contain.
Description ........................................................................................................................
...........................................................................................................................................
[2]
(b) Complete the following table by giving the appropriate data type in each case.
(c) An airline wants to provide passengers with information about individual flights and allow
them to book their flight using an online booking system.
(i) Tick (3) one box in each row of the table to indicate whether each item of information
would be essential for the customer when making the booking.
(ii) Identify the technique used to filter out information that is not essential when designing
the booking system and state one benefit of this technique.
Technique ..........................................................................................................................
Benefit ...............................................................................................................................
...........................................................................................................................................
[2]
(iii) Identify two additional pieces of essential information that a passenger might need
when booking a flight.
1 ........................................................................................................................................
2 ........................................................................................................................................
[2]
BLANK PAGE
Apply the process of stepwise refinement to this algorithm in order to produce a more detailed
description.
Write the more detailed description using structured English. Your explanation of the
algorithm should not include pseudocode statements.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
START
Set Count to 1
Is Flag = YES
FALSE AND
Count <= 5 ?
NO
ReBoot()
Is Flag = YES
FALSE ?
NO
Alert(27)
END
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
............................................................................................................................................................ [6]
3 (a) The diagram below represents a queue Abstract Data Type (ADT) that can hold a maximum
of eight items.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
(ii) Describe how the next item in the given queue is removed and stored in the variable
AnimalName.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
(iii) Describe the state of the queue when the front of queue and the end of queue pointers
have the same value.
...........................................................................................................................................
..................................................................................................................................... [1]
(b) Some operations are carried out on the original queue given in part (a).
0 Frog
1 Cat
2 Fish
3 Elk
4
5
6
7
Complete the diagram to show the state of the queue after the following operations:
Add “Wasp”, “Bee” and “Mouse”, and then remove two data items.
[3]
(ii) The state of the queue after other operations are carried out is shown:
0 Frog
1 Cat
2 Fish
3 Elk Front of queue pointer
4 Wasp
5 Bee
6 Mouse End of queue pointer
7 Ant
Complete the following diagram to show the state of the queue after the following
operations:
0
1
2
3
4
5
6
7
[2]
© UCLES 2021 9618/21/O/N/21 [Turn over
10
Describe the algorithm that should be used to modify the end of queue pointer when adding
an item to the queue.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
Part of the program involves reading a value from a sensor. The sensor produces a numeric value
that represents the temperature. The value is an integer, which should be in the range 0 to 40
inclusive.
A program function has been written to validate the values from the sensor.
Complete the table. The first line has been completed for you.
You can assume that the sensor will generate only integer data values.
(b) A program module controls the heaters. This module operates as follows:
Start
Heaters Heaters
Off On
[3]
5 The following data items will be recorded each time a student successfully logs on to the school
network:
The Student ID is six characters long. The other two data items are of variable length.
A single string will be formed by concatenating the three data items. A separator character will
need to be inserted between items two and three.
For example:
A programmer decides to store the concatenated strings in a 1D array LogArray that contains
2000 elements. Unused array elements will contain an empty string.
(a) Suggest a suitable separator character and give a reason for your choice.
Character ..................................................................................................................................
Reason .....................................................................................................................................
...................................................................................................................................................
[2]
(b) The choice of data structure was made during one stage of the program development life
cycle.
............................................................................................................................................. [1]
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [7]
© UCLES 2021 9618/21/O/N/21 [Turn over
14
6 A mobile phone has a touchscreen. The screen is represented by a grid, divided into 800 rows
and 1280 columns.
The grid is represented by a 2D array Screen of type INTEGER. An array element will be set to 0
unless the user touches that part of the screen.
The following diagram shows a simplified touchscreen. The dark line represents a touch to the
screen. All grid elements that are wholly or partly inside the outline will be set to 1. These elements
are shaded.
The element shaded in black represents the centre point.
11
A program is needed to find the coordinates (the row and column) of the centre point. The centre
point on the diagram above is row 6, column 11.
Assume:
Module Description
• Called with three parameters of type INTEGER:
SetRow() ◦a row number
(generates test ◦the number of pixels to be skipped starting from column 1
data) ◦the number of pixels that should be set to 1
• Sets the required number of pixels to 1
For example, SetRow(3, 8, 5) will give row 3 as in the diagram shown.
• Takes two parameters of type INTEGER:
◦a row number
◦a start column (1 or 1280)
SearchInRow() • Searches the given row from the start column (either left to right or right to left)
for the first column that contains an element set to 1
• Returns the column number of the first element in the given row that is set to 1
• Returns −1 if no element is set to 1
• Takes two parameters of type INTEGER:
◦
a column number
◦
a start row (1 or 800)
SearchInCol() • Searches the given column from the start row (either up or down) for the first
row that contains an element set to 1
• Returns the row number of the first element in the given column that is set to 1
• Returns −1 if no element is set to 1
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [5]
Module Description
• Takes two parameters of type INTEGER:
◦a row number
◦a start column (1 or 1280)
SearchInRow() • Searches the given row from the start column (either left to right or right to left)
for the first column that contains an element set to 1
• Returns the column number of the first element in the given row that is set to 1
• Returns −1 if no element is set to 1
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
© UCLES 2021 9618/21/O/N/21
17
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [8]
Module Description
• Called with a row number as an INTEGER
• Uses SearchInRow() to find the first and last columns in the given row which
GetCentreCol() have an array element set to 1
• Returns the index of the column midway between the first and last columns
• Returns −1 if no element is set to 1
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[6]
© UCLES 2021 9618/21/O/N/21
18
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.
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 (LK/CGW) 213669/3
© UCLES 2021 [Turn over
2
Refer to the insert for the list of pseudocode functions and operators.
1 (a) A programmer applies decomposition to a problem that she has been asked to solve.
Describe decomposition.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]
ThisArray[n] ← 42
Complete the following table by writing the answer for each row.
Answer
(c) Complete the pseudocode expressions so that they evaluate to the values shown.
Expression Evaluates to
67
.......................................... ('C')
54
2 * ......................................... ("27")
13
................................ (27 / .................................)
[4]
(d) Evaluate the expressions given in the following table. The variables have been assigned
values as follows:
PumpOn ← TRUE
←
PressureOK TRUE
HiFlow ← FALSE
Expression Evaluates to
PumpOn OR PressureOK
[5]
© UCLES 2021 9618/22/O/N/21 [Turn over
6
The school principal has some ideas about the appearance of the website but is unclear
about all the details of the solution. The principal would like to see an initial version of the
website.
(i) Identify a life cycle method that would be appropriate in this case.
Reason ..............................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
[2]
State three activities that will take place during the design stage of the program
development life cycle.
1 ........................................................................................................................................
2 ........................................................................................................................................
3 ........................................................................................................................................
[3]
BLANK PAGE
Data will be stored about each student in the school and each student may join up to three clubs.
The programmer has started to define the fields that will be needed as shown in the following
table.
(a) (i) Write pseudocode to declare the record structure for type Student.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [3]
(ii) A 1D array Membership containing 3000 elements will be used to store the student
data.
...........................................................................................................................................
..................................................................................................................................... [2]
...........................................................................................................................................
..................................................................................................................................... [1]
...........................................................................................................................................
..................................................................................................................................... [1]
© UCLES 2021 9618/22/O/N/21
9
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
© UCLES 2021 9618/22/O/N/21 [Turn over
10
(a) Complete the following table by giving the answers, using the given pseudocode.
Answer
A line number containing a variable being incremented
(b) The pseudocode includes several features that make it easier to read and understand.
1 ................................................................................................................................................
2 ................................................................................................................................................
3 ................................................................................................................................................
[3]
(c) (i) The loop structure used in the pseudocode is not the most appropriate.
Justification .......................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
[2]
(ii) The appropriate loop structure is now used. Two lines of pseudocode are changed and
two lines are removed.
Write the line numbers of the two lines that are removed.
...........................................................................................................................................
..................................................................................................................................... [1]
5 A company has several departments. Each department stores the name, email address and the
status of each employee in that department in its own text file. All text files have the same format.
Employee details are stored as three separate data strings on three consecutive lines of the file.
An example of the first six lines of one of the files is as follows:
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
© UCLES 2021 9618/22/O/N/21
13
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
...........................................................................................................................................
..................................................................................................................................... [1]
(ii) State one advantage and one disadvantage of the alternative format.
Advantage .........................................................................................................................
...........................................................................................................................................
Disadvantage ....................................................................................................................
...........................................................................................................................................
[2]
BLANK PAGE
6 A mobile phone has a touchscreen. The screen is represented by a grid, divided into 800 rows
and 1280 columns.
The grid is represented by a 2D array Screen of type INTEGER. An array element will be set to 0
unless the user touches that part of the screen.
The following diagram shows a simplified touchscreen. The dark line represents a touch on the
screen. All grid elements that are wholly or partly inside the outline will be set to 1. These elements
are shaded.
The element shaded in black represents the centre point of the touch.
11
A program is needed to find the coordinates (the row and column) of the centre point. The centre
point on the diagram shown is row 6, column 11.
Assume:
The programmer has decided to use global values CentreRow and CentreCol as coordinate
values for the centre point.
Module Description
• Searches for the first row that has an array element set to 1
FirstRowSet() • Returns the index of that row (1 is the first row)
• Returns −1 if there are no elements set to 1
• Searches for the last row that has an array element set to 1
LastRowSet() • Returns the index of that row
• Returns −1 if there are no elements set to 1
• Searches for the first column that has an array element set to 1
FirstColSet() • Returns the index of that column (1 is the first column)
• Returns −1 if there are no elements set to 1
• Searches for the last column that has an array element set to 1
LastColSet() • Returns the index of that column
• Returns −1 if there are no elements set to 1
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
© UCLES 2021 9618/22/O/N/21 [Turn over
18
(b) Describe a feature of your solution to part (a) that indicates the pseudocode represents an
efficient algorithm.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]
(c) The programmer decides to produce a single search module FindSet(), which will be able
to perform each of the individual searches performed by the first four modules in the table.
(i) Outline the changes needed to convert one of the existing modules into this single
module.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
(ii) Give one possible advantage and one possible disadvantage of combining the four
searches into a single module.
Advantage .........................................................................................................................
...........................................................................................................................................
Disadvantage ....................................................................................................................
...........................................................................................................................................
[2]
Module Description
• Calculates the coordinates of the centre point
• Uses the four modules: FirstRowSet(), LastRowSet(),
GetCentre() FirstColSet(), LastColSet()
• Assigns values to CentreRow and CentreCol
• Sets CentreRow to −1 if no screen touch is detected
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
© UCLES 2021 9618/22/O/N/21
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 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.
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 (CE/CGW) 213696/3
© UCLES 2021 [Turn over
2
Refer to the insert for the list of pseudocode functions and operators.
1 Sylvia is testing a program that has been written by her colleague. Her colleague tells her that the
program does not contain any syntax errors.
(a) (i) State what her colleague means by “does not contain any syntax errors”.
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [1]
(ii) Identify and describe one other type of error that the program may contain.
Description ........................................................................................................................
...........................................................................................................................................
[2]
(b) Complete the following table by giving the appropriate data type in each case.
(c) An airline wants to provide passengers with information about individual flights and allow
them to book their flight using an online booking system.
(i) Tick (3) one box in each row of the table to indicate whether each item of information
would be essential for the customer when making the booking.
(ii) Identify the technique used to filter out information that is not essential when designing
the booking system and state one benefit of this technique.
Technique ..........................................................................................................................
Benefit ...............................................................................................................................
...........................................................................................................................................
[2]
(iii) Identify two additional pieces of essential information that a passenger might need
when booking a flight.
1 ........................................................................................................................................
2 ........................................................................................................................................
[2]
BLANK PAGE
Apply the process of stepwise refinement to this algorithm in order to produce a more detailed
description.
Write the more detailed description using structured English. Your explanation of the
algorithm should not include pseudocode statements.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
START
Set Count to 1
Is Flag = YES
FALSE AND
Count <= 5 ?
NO
ReBoot()
Is Flag = YES
FALSE ?
NO
Alert(27)
END
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
..................................................................................................................................................................
............................................................................................................................................................ [6]
3 (a) The diagram below represents a queue Abstract Data Type (ADT) that can hold a maximum
of eight items.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
(ii) Describe how the next item in the given queue is removed and stored in the variable
AnimalName.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
(iii) Describe the state of the queue when the front of queue and the end of queue pointers
have the same value.
...........................................................................................................................................
..................................................................................................................................... [1]
(b) Some operations are carried out on the original queue given in part (a).
0 Frog
1 Cat
2 Fish
3 Elk
4
5
6
7
Complete the diagram to show the state of the queue after the following operations:
Add “Wasp”, “Bee” and “Mouse”, and then remove two data items.
[3]
(ii) The state of the queue after other operations are carried out is shown:
0 Frog
1 Cat
2 Fish
3 Elk Front of queue pointer
4 Wasp
5 Bee
6 Mouse End of queue pointer
7 Ant
Complete the following diagram to show the state of the queue after the following
operations:
0
1
2
3
4
5
6
7
[2]
© UCLES 2021 9618/23/O/N/21 [Turn over
10
Describe the algorithm that should be used to modify the end of queue pointer when adding
an item to the queue.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
Part of the program involves reading a value from a sensor. The sensor produces a numeric value
that represents the temperature. The value is an integer, which should be in the range 0 to 40
inclusive.
A program function has been written to validate the values from the sensor.
Complete the table. The first line has been completed for you.
You can assume that the sensor will generate only integer data values.
(b) A program module controls the heaters. This module operates as follows:
Start
Heaters Heaters
Off On
[3]
5 The following data items will be recorded each time a student successfully logs on to the school
network:
The Student ID is six characters long. The other two data items are of variable length.
A single string will be formed by concatenating the three data items. A separator character will
need to be inserted between items two and three.
For example:
A programmer decides to store the concatenated strings in a 1D array LogArray that contains
2000 elements. Unused array elements will contain an empty string.
(a) Suggest a suitable separator character and give a reason for your choice.
Character ..................................................................................................................................
Reason .....................................................................................................................................
...................................................................................................................................................
[2]
(b) The choice of data structure was made during one stage of the program development life
cycle.
............................................................................................................................................. [1]
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [7]
© UCLES 2021 9618/23/O/N/21 [Turn over
14
6 A mobile phone has a touchscreen. The screen is represented by a grid, divided into 800 rows
and 1280 columns.
The grid is represented by a 2D array Screen of type INTEGER. An array element will be set to 0
unless the user touches that part of the screen.
The following diagram shows a simplified touchscreen. The dark line represents a touch to the
screen. All grid elements that are wholly or partly inside the outline will be set to 1. These elements
are shaded.
The element shaded in black represents the centre point.
11
A program is needed to find the coordinates (the row and column) of the centre point. The centre
point on the diagram above is row 6, column 11.
Assume:
Module Description
• Called with three parameters of type INTEGER:
SetRow() ◦a row number
(generates test ◦the number of pixels to be skipped starting from column 1
data) ◦the number of pixels that should be set to 1
• Sets the required number of pixels to 1
For example, SetRow(3, 8, 5) will give row 3 as in the diagram shown.
• Takes two parameters of type INTEGER:
◦a row number
◦a start column (1 or 1280)
SearchInRow() • Searches the given row from the start column (either left to right or right to left)
for the first column that contains an element set to 1
• Returns the column number of the first element in the given row that is set to 1
• Returns −1 if no element is set to 1
• Takes two parameters of type INTEGER:
◦
a column number
◦
a start row (1 or 800)
SearchInCol() • Searches the given column from the start row (either up or down) for the first
row that contains an element set to 1
• Returns the row number of the first element in the given column that is set to 1
• Returns −1 if no element is set to 1
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [5]
Module Description
• Takes two parameters of type INTEGER:
◦a row number
◦a start column (1 or 1280)
SearchInRow() • Searches the given row from the start column (either left to right or right to left)
for the first column that contains an element set to 1
• Returns the column number of the first element in the given row that is set to 1
• Returns −1 if no element is set to 1
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
© UCLES 2021 9618/23/O/N/21
17
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [8]
Module Description
• Called with a row number as an INTEGER
• Uses SearchInRow() to find the first and last columns in the given row which
GetCentreCol() have an array element set to 1
• Returns the index of the column midway between the first and last columns
• Returns −1 if no element is set to 1
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...............................................................................................................................................[6]
© UCLES 2021 9618/23/O/N/21
18
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.
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 (RW/CGW) 303754/3
© UCLES 2022 [Turn over
2
Refer to the insert for the list of pseudocode functions and operators.
1 (a) A programmer draws a program flowchart to show the sequence of steps required to solve a
problem.
Give the technical term for a sequence of steps that describe how to solve a problem.
...................................................................................................................................................
............................................................................................................................................. [1]
(i) Complete the table by writing the most appropriate data type for each variable.
[4]
(ii) One of the names used for a variable in the table in part 1(b)(i) is not an example of
good practice.
Identify the variable and give a reason why it is not good practice to use that name.
Variable .............................................................................................................................
Reason ..............................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
[2]
Expression Evaluation
INT((31 / 3) + 1)
MID(TO_UPPER("Version"), 4, 2)
NUM_TO_STR(27 MOD 3)
[4]
Button-Y
Button-Z | Output-C
START
S1 Button-Z S3
Button-Y
Button-Y | Output-A
Button-X
S2
S4
Button-Z | Output-B
Answer
The number of different inputs
Complete the table to show the inputs, outputs and next states.
Button-Y
none
Button-Z S2
none
[4]
3 The manager of a cinema wants a program to allow users to book seats. The cinema has several
screens. Each screen shows a different film.
(a) Decomposition will be used to break the problem down into sub-problems.
Module 1 ...................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Module 2 ...................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Module 3 ...................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[3]
(b) Two types of program modules may be used in the design of the program.
Identify the type of program module that should be used to return a value.
............................................................................................................................................. [1]
BLANK PAGE
4 A stack is created using a high-level language. Memory locations 200 to 207 are to be used to
store the stack.
Stack Pointer
Memory
Value
location
200
201
202
204 'C'
205 'D'
206 'E'
207 'H'
Answer
The value that has been on the stack for the longest time.
[2]
(b) The following diagram shows the current state of the stack:
Stack Pointer
Memory
Value
location
200
201
203 'Y'
204 'X'
205 'Z'
206 'N'
207 'P'
POP
POP
PUSH 'A'
PUSH 'B'
POP
PUSH 'C'
PUSH 'D'
Complete the diagram to show the state of the stack after the operations have been
performed.
Stack Pointer
Memory
Value
location
200
201
202
203
204
205
206
207
[4]
5 Each line of a text file contains data organised into fixed-length fields as shown:
An algorithm is required to search for the first instance of a given value of Field 2 and, if found, to
output the corresponding values for Field 1 and Field 3.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [6]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [5]
CASE OF MySwitch
1: ThisChar 'a'
2: ThisChar 'y'
3: ThisChar '7'
OTHERWISE: ThisChar '*'
ENDCASE
Write pseudocode with the same functionality without using a CASE structure.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
Upper-case and lower-case characters need to be treated the same. For example, 'A' is equivalent
to 'a'.
(a) A function IsPalindrome() will take a string parameter. The function will return TRUE if the
string is a palindrome and will return FALSE if the string is not a palindrome.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
For example, the string "never odd or even" becomes a palindrome if the spaces are removed.
START
Set Index to 1
NO
B
E
YES
F
C
D
END
Complete the table by writing the text that should replace each of the labels B, C, D, F and G.
Label Text
G
[4]
© UCLES 2022 9618/21/M/J/22 [Turn over
14
8 A program allows a user to save passwords used to login to websites. A stored password is
inserted automatically when the user logs into the corresponding website.
A student is developing a program to generate a password. The password will be of a fixed format,
consisting of three groups of four alphanumeric characters. The groups are separated by the
hyphen character '-'.
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.
Secret[27, 1] "www.thiswebsite.com"
Secret[27, 2] ""
Secret[28, 1] "www.thatwebsite.com"
Secret[28, 2] ""
Note:
• For security, passwords are stored in an encrypted form, shown as "" in the
example.
• The passwords cannot be used without being decrypted.
• Assume that the encrypted form of a password will not be an empty string.
Module Description
RandomChar() • Generates a single random character from within one of the
following ranges:
○ 'a' to 'z'
○ 'A' to 'Z'
○ '0' to '9'
• Returns the character
Encrypt() • Takes a password as a parameter of type string
• Returns the encrypted form of the password as a string
Decrypt() • Takes an encrypted password as a parameter of type string
• Returns the decrypted form of the password as a string
'A' to 'Z' 65 to 90
'0' to '9' 48 to 57
You may wish to refer to the insert for a description of the CHR() function. Other functions
may also be required.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
Module Description
FindPassword() • Takes a website domain name as a parameter of type string
• Searches for the website domain name in the array Secret
• If the website domain name is found, the decrypted password
is returned
• If the website domain name is not found, a warning message
is output, and an empty string is returned
Assume that modules Encrypt() and Decrypt() have already been written.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
© UCLES 2022 9618/21/M/J/22
17
(c) The modules Encrypt() and Decrypt() are called from several places in the main
program.
Identify a method that could have been used to test the main program before these modules
were completed. Describe how this would work.
Method ......................................................................................................................................
Description ................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
(d) A validation function is written to check that the passwords generated are valid.
Note: lower-case and upper-case characters are not the same. For example, 'a' is not the
same as 'A'.
Give two password strings that could be used to test different areas of the validation rules.
Password 1 ...............................................................................................................................
Password 2 ...............................................................................................................................
[2]
(e) The RandomChar() module is to be modified so that alphabetic characters are generated
twice as often as numeric characters.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
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 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.
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
2
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
9
(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]
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 ','.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
ENDPROCEDURE [7]
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]
BLANK PAGE
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
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [5]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [8]
(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
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
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.
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 (PQ/CGW) 303773/3
© UCLES 2022 [Turn over
2
Refer to the insert for the list of pseudocode functions and operators.
Complete the table by placing one or more ticks (✓) in each row.
INPUT MyName
IF Mark > 74 THEN
Grade 'A'
ENDIF
[5]
Variable Value
AAA TRUE
BBB FALSE
Count 99
Expression Evaluation
...........................................................................................................................................
..................................................................................................................................... [1]
2 A program has been written to implement a website browser and maintenance is now required.
Name two other types of maintenance that the program may require and give a reason for each.
Type 1 ..............................................................................................................................................
Reason .............................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
Type 2 ..............................................................................................................................................
Reason .............................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
[4]
PROCEDURE Section_1()
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]
(b) Module Section_1() calls one of the other three modules. The module called will be
selected when the program runs.
[5]
© UCLES 2022 9618/23/M/J/22
5
4 Items in a factory are weighed automatically. The weight is stored as an integer value representing
the item weight to the nearest gram (g).
A function is written to validate the weight of each item. The function will return "PASS" if the
weight of the item is within the acceptable range, otherwise the function will return "FAIL".
The validation function is to be properly tested. Black-box testing will be used and a test plan
needs to be produced.
[4]
The data will be held in a record structure of type Employee. The fields that will be needed are as
shown:
(a) (i) Write pseudocode to declare the record structure for type Employee.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [4]
(ii) A 1D array Staff containing 500 elements will be used to store the employee records.
...........................................................................................................................................
..................................................................................................................................... [2]
(b) There may be more records in the array than there are employees in the company. In this
case, some records of the array will be unused.
(i) State why it is good practice to have a standard way to indicate unused array elements.
...........................................................................................................................................
..................................................................................................................................... [1]
(ii) Give one way of indicating an unused record in the Staff array.
...........................................................................................................................................
..................................................................................................................................... [1]
(c) A procedure Absentees() will output the EmployeeNumber and the Name of all employees
who have an Attendance value of 90.00 or less.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
6 (a) The factorial of a number is the product of all the integers from 1 to that number.
For example:
factorial of 5 is given by 1 × 2 × 3 × 4 × 5 = 120
factorial of 7 is given by 1 × 2 × 3 × 4 × 5 × 6 × 7 = 5040
factorial of 1 = 1
Note: factorial of 0 = 1
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
(b) A procedure FirstTen() will output the factorial of the numbers from 0 to 9. The procedure
will use the function from part (a).
Factorial of 0 is 1
Factorial of 1 is 1
Factorial of 2 is 2
Factorial of 9 is 362880
START
Set Num to 0
C
A
F
B
D
END
Complete the table by writing the text that should replace each label A to F.
Label Text
F
[4]
© UCLES 2022 9618/23/M/J/22 [Turn over
10
7 The following pseudocode represents an algorithm intended to output the last three lines as they
appear in a text file. Line numbers are provided for reference only.
(a) There is an error in the algorithm. In certain cases, a text file will have at least three lines but
the output will be incorrect.
...........................................................................................................................................
..................................................................................................................................... [1]
(ii) Describe the error in the algorithm and explain how it may be corrected.
Description ........................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
Explanation .......................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
[4]
(b) The original algorithm is implemented and sometimes the last three lines of the text file are
output correctly.
...................................................................................................................................................
............................................................................................................................................. [1]
...................................................................................................................................................
............................................................................................................................................. [2]
8 The following diagram shows the incomplete waterfall model of the program development life
cycle.
Analysis
Maintenance
[3]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[2]
(c) Identify another type of model for the program development life cycle.
............................................................................................................................................. [1]
BLANK PAGE
9 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 student is developing a program to generate a strong password. The password will be of a fixed
format, consisting of three groups of four alphanumeric characters, separated by the hyphen
character '-'.
A valid password:
• must be 14 characters long
• must be organised as three groups of four alphanumeric characters. The groups are
separated by hyphen characters
• may include duplicated characters, provided these appear in different groups.
Module Description
• 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
• 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 valid password
Generate() • Uses RandomChar() and Exists()
• Returns the password
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
(b) 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.
Secret[27, 1] "www.thiswebsite.com"
Secret[27, 2] "●●●●●●●●●●●●"
Secret[28, 1] "www.thatwebsite.com"
Secret[28, 2] "●●●●●●●●●●●●"
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 a password as a string
Encrypt()
• Returns the encrypted form of the password as a string
• Takes an encrypted password as a string
Decrypt()
• Returns the decrypted form of the password as a string
• Takes a website domain name as a string
• Searches for the website domain name in the array Secret
FindPassword() • If the website domain name is found, the decrypted password is
returned
• If the website domain name is not found, an empty string is
returned
• Takes two parameters as strings: a website domain name and a
password
• Searches for the website domain name in the array Secret and
AddPassword() if not found, adds the website domain name and the encrypted
password to the array
• Returns TRUE if the website domain name and encrypted
password are added to the array, otherwise returns FALSE
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
(c) The content of the array Secret is to be stored in a text file for backup.
It must be possible to read the data back from the file and extract the website domain name
and the encrypted password.
Both the website domain name and encrypted password are stored in the array as strings of
characters.
The encrypted password may contain any character from the character set used and the
length of both the encrypted password and the website domain name is variable.
Explain how a single line of the text file can be used to store the website domain name and
the encrypted password.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
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 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.
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 (PQ) 302745/3
© UCLES 2022 [Turn over
2
Refer to the insert for the list of pseudocode functions and operators.
State three possible benefits of using library routines in the development of the program.
1 ................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
...................................................................................................................................................
3 ................................................................................................................................................
...................................................................................................................................................
[3]
(b) The following pseudocode is part of a program that stores names and test marks for use in
other parts of the program.
(i) The pseudocode needs to be changed to allow for data to be stored for up to 30 students.
Explain why it would be good practice to use arrays to store the data.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [3]
State the purpose of the variable Count and give its data type.
Purpose .............................................................................................................................
...........................................................................................................................................
(c) 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.
Assume that any variables used are of the correct type for the given function.
Statement Error
2 A system is being developed to help manage a car hire business. A customer may hire a car for a
number of days.
(a) Explain the process of abstraction and state four items of data that should be stored each
time a car is hired.
Explanation ...............................................................................................................................
...................................................................................................................................................
Item 1 ........................................................................................................................................
Item 2 ........................................................................................................................................
Item 3 ........................................................................................................................................
Item 4 ........................................................................................................................................
[3]
(b) Identify two operations that would be required to process the car hire data.
Operation 1 ...............................................................................................................................
...................................................................................................................................................
Operation 2 ...............................................................................................................................
...................................................................................................................................................
[2]
3 A 1D array Data of type integer contains 200 elements. Each element has a unique value.
An algorithm is required to search for the largest value and output it.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [5]
4 (a) The following diagram shows an Abstract Data Type (ADT) representation of an ordered
linked list. The data item stored in each node is a single character. The data will be accessed
in alphabetical order.
Start pointer
(i) Nodes with data 'A' and 'K' are added to the linked list. Nodes with data 'J' and 'L' are
deleted.
After the changes, the data items still need to be accessed in alphabetical order.
Complete the diagram to show the new state of the linked list.
Start pointer
[4]
(ii) The original data could have been stored in a 1D array in which each element stores a
character.
For example:
Explain the advantages of making the changes described in part (a)(i) when the data is
stored in the linked list instead of an array.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
© UCLES 2022 9618/21/O/N/22
7
(iii) Explain the disadvantages of making the changes described in part (a)(i) when the data
is stored in the linked list instead of an array.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
(b) A program will store data using a linked list like the one shown in part (a).
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
5 A program uses two 1D arrays of type integer. Array1 contains 600 elements and Array2
contains 200 elements.
Array1 contains sample values read from a sensor. The sensor always takes three consecutive
samples and all of these values are stored in Array1.
A procedure Summarise() will calculate the average of three consecutive values from Array1
and write the result to Array2. This will be repeated for all values in Array1.
The diagram below illustrates the process for the first six entries in Array1.
}
Array1 Array2 Comment
}
15
40
41
42
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [5]
BLANK PAGE
6 The following pseudocode algorithm attempts to check whether a string is a valid email address.
Index ← 1
Dots ←0
Ats 0←
Others ← 0
Valid ← TRUE
REPEAT
NextChar ←
MID(InString, Index, 1)
CASE OF NextChar
'.' : Dots Dots + 1 ←
'@' : Ats Ats + 1 ←
IF Ats > 1 THEN
Valid FALSE ←
ENDIF
OTHERWISE : Others Others + 1 ←
ENDCASE
RETURN Valid
ENDFUNCTION
State the values that would result in the condition evaluating to TRUE.
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [1]
(b) (i) Complete the trace table by dry running the function when it is called as follows:
Result ← IsValid("Liz.123@big@net")
Index NextChar Dots Ats Others Valid
[5]
(ii) State the value returned when IsValid() is called using the expression shown in
part (b)(i).
..................................................................................................................................... [1]
<Value1><Operator><Value2>
Assume:
• the string contains only numeric digits and a single operator character
• Value1 and Value2 represent integer values
• Value1 and Value2 are unsigned (they will not be preceded by ' + ' or ' − ').
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [7]
(ii) Calculate() is changed to a function that returns the value of the evaluated
expression.
...........................................................................................................................................
..................................................................................................................................... [1]
(b) A string representing an arithmetic expression could be in the correct format but be impossible
to evaluate.
Give an example of a correctly formatted string and explain why evaluation would be
impossible.
Explanation ...............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[2]
Module Description
• takes the name of an existing project file as a parameter of type
string
CheckFile()
• returns TRUE if the file is valid (it contains at least 10 non-blank
lines), otherwise returns FALSE
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
Module Description
• takes a line from a project file as a parameter of type string
CheckLine() • returns zero if the line is blank or contains no syntax error,
otherwise returns an error number as an integer
• takes two parameters:
○ the name of a project file as a string
○ the maximum number of errors as an integer
• uses CheckFile() to test the project file. Outputs an error
CountErrors() message and ends if the project file is not valid
• calls CheckLine() for each line in the project file
• counts the number of errors
• outputs the number of errors or a warning message if the
maximum number of errors is exceeded
(b) CountErrors() is called to check the project file Jim01Prog.txt and to stop if more than
20 errors are found.
...................................................................................................................................................
............................................................................................................................................. [2]
(c) Write pseudocode for module CountErrors(). Assume CheckFile() and CheckLine()
have been written and can be used in your solution.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
© UCLES 2022 9618/21/O/N/22
17
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [8]
Two examples of syntax error that cannot be detected from examining a single line are
those involving selection and iteration.
1 ................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[2]
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 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.
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 (LK/JG) 302746/2
© UCLES 2022 [Turn over
2
Refer to the insert for the list of pseudocode functions and operators.
1 (a) A programmer is developing an algorithm to solve a problem. Part of the algorithm would be
appropriate to implement as a subroutine (a procedure or a function).
(i) State two reasons why the programmer may decide to use a subroutine.
1 ........................................................................................................................................
...........................................................................................................................................
2 ........................................................................................................................................
...........................................................................................................................................
[2]
Give the correct term for the identifiers Count and Message and explain their use.
Term ..................................................................................................................................
Use ....................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
[2]
(b) The algorithm in part (a) is part of a program that will be sold to the public.
All the software errors that were identified during in-house testing have been corrected.
Identify and describe the additional test stage that may be carried out before the program is
sold to the public.
Description ................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[4]
Complete the table by evaluating each expression using the example values.
Expression Evaluation
MID(CharList, MONTH(FlagDay), 1)
INT(Count / LENGTH(CharList))
(Count >= 29) AND (DAY(FlagDay) > 23)
[3]
2 (a) An algorithm will process data from a test taken by a group of students. The algorithm will
prompt and input the name and test mark for each of the 35 students.
The algorithm will add the names of all the students with a test mark of less than 20 to an
existing text file Support_List.txt, which already contains data from other group tests.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [5]
(ii) Explain why it may be better to store the names of the students in a file rather than in an
array.
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [1]
(iii) Explain why WRITE mode cannot be used in the answer to part 2(a)(i).
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [1]
Input-A Output-X
Input-B Output-W
Input-B
START
S1 S2
S3
Input-A
Input-A
Input-B
S4 Input-A Output-W
Complete the table to show the inputs, outputs and next states.
S1
Input-A
S2
Output-W
Output-W
[4]
3 A stack is used in a program to store string data which needs to be accessed in several modules.
Identify one other example of an ADT and describe its main features.
Example ....................................................................................................................................
Features ...................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[3]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [5]
(c) A second stack is used in the program. The diagram below shows the initial state of this
stack. Value X is at the top of the stack and was the last item added.
Group 1:
PUSH D
PUSH E
Group 2:
POP
POP
POP
Group 3:
PUSH A
PUSH B
POP
PUSH C
Complete the diagram to show the state of the stack after each group of operations has been
performed.
957
956
955
954
953 X ←SP
952 Y
951 Z
950 P
[5]
BLANK PAGE
START
INPUT UserID
Set Average to
GetAverage(UserID)
Set Total to 0
Set Index to 4
Add 1 to Index
YES
Is Index < 7 ?
NO Set Last to
SameMonth[Index]
Is Average NO
> Last ? Add Last to Total
YES
Update(UserID, Total)
END
(a) Write the equivalent pseudocode for the algorithm represented by the flowchart.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
............................................................................................................................................. [1]
IF A = TRUE THEN
IF B = TRUE THEN
IF C = TRUE THEN
CALL Sub1()
ELSE
CALL Sub2()
ENDIF
ENDIF
ELSE
IF B = TRUE THEN
IF C = TRUE THEN
CALL Sub4()
ELSE
CALL Sub3()
ENDIF
ELSE
IF C = FALSE THEN
CALL Sub3()
ELSE
CALL Sub4()
ENDIF
ENDIF
ENDIF
1 .......................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
2 .......................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
3 .......................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
4 .......................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
[4]
© UCLES 2022 9618/22/O/N/22
11
BLANK PAGE
6 (a) The factorial of an integer number is the product of all the integers from that number down
to 1.
For example:
You may use the rest of this page for rough working.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
(b) A program is written to allow a user to input a sequence of values to be checked using the
function FindBaseNumber().
The user will input one value at a time. The variable used to store the user input has to be of
type string because the user will input ‘End’ to end the program.
Valid input will be converted to an integer and passed to FindBaseNumber() and the return
value will be output.
Complete the table by giving four invalid strings that may be used to test distinct aspects of
the required validation. Give the reason for your choice in each case.
......................................................................................................
......................................................................................................
......................................................................................................
......................................................................................................
......................................................................................................
......................................................................................................
......................................................................................................
......................................................................................................
......................................................................................................
......................................................................................................
......................................................................................................
......................................................................................................
[4]
BLANK PAGE
Two global 1D arrays are used to store the syntax error data. Both arrays contain 500 elements.
• Array ErrCode contains integer values that represent an error number in the range 1 to 800.
• Array ErrText contains string values that represent an error description.
Note:
• There may be less than 500 error numbers so corresponding elements in both arrays may be
unused. Unused elements in ErrCode have the value 999. The value of unused elements in
ErrText is undefined.
• Values in the ErrCode array are stored in ascending order but not all values may be present,
for example, there may be no error code 31.
Module Description
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
(b) Write an efficient bubble sort algorithm in pseudocode for module SortArrays().
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [8]
(c) Two 1D arrays were described at the beginning of the question. Both arrays contain 500
elements.
• Array ErrCode contains integer values that represent an error number in the range
1 to 800.
• Array ErrText contains string values that represent an error description.
The two arrays will be replaced by a single array. A user-defined data type (record structure)
has been declared as follows:
TYPE ErrorRec
DECLARE ErrCode : STRING
DECLARE ErrText : STRING
ENDTYPE
...........................................................................................................................................
..................................................................................................................................... [1]
(ii) State two benefits of using the single array of the user-defined data type.
1 ........................................................................................................................................
...........................................................................................................................................
2 ........................................................................................................................................
...........................................................................................................................................
[2]
..................................................................................................................................... [1]
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.
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 (NF/CB) 302729/4
© UCLES 2022 [Turn over
2
Refer to the insert for the list of pseudocode functions and operators.
(a) Part of the program requires four variables. The following table describes the use of each
variable.
Complete the table by adding the most appropriate data type for each variable.
[4]
(b) The designer considers the use of a development life cycle to split the development of the
website into several stages.
(i) State one benefit of a development life cycle when developing the website.
...........................................................................................................................................
..................................................................................................................................... [1]
State one document that may be produced from the analysis stage of the website project.
...........................................................................................................................................
..................................................................................................................................... [1]
(c) The program will be developed using the Rapid Application Development (RAD) life cycle.
...........................................................................................................................................
..................................................................................................................................... [1]
(ii) Give two benefits and one drawback of its use compared to the waterfall life cycle.
Benefit 1 ............................................................................................................................
...........................................................................................................................................
Benefit 2 ............................................................................................................................
...........................................................................................................................................
Drawback ..........................................................................................................................
...........................................................................................................................................
[3]
1 ................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
...................................................................................................................................................
[2]
2 A program is being designed for a smartphone to allow users to send money to the charity of their
choice.
Identify three program modules that could be used in the design and describe their use.
Module 1 ..........................................................................................................................................
Use ...................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
Module 2 ..........................................................................................................................................
Use ...................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
Module 3 ..........................................................................................................................................
Use ...................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
[3]
Describe the algorithm needed. Do not include pseudocode statements in your answer.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [5]
State the one additional piece of information required before the array can be declared.
...................................................................................................................................................
............................................................................................................................................. [1]
(b) A programmer decides to implement a queue Abstract Data Type (ADT) in order to store
characters received from the keyboard. The queue will need to store at least 10 characters
and will be implemented using an array.
(i) Describe two operations that are typically required when implementing a queue.
State the check that must be carried out before each operation can be completed.
Operation 1 .......................................................................................................................
...........................................................................................................................................
Check 1 .............................................................................................................................
...........................................................................................................................................
Operation 2 .......................................................................................................................
...........................................................................................................................................
Check 2 .............................................................................................................................
...........................................................................................................................................
[4]
(ii) Describe the declaration and initialisation of the variables and data structures used to
implement the queue.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [5]
© UCLES 2022 9618/23/O/N/22
7
<StockID><Description><Cost>
Item Length
StockID 5
Description 32
Cost the remainder of the string
A procedure Unpack() takes four parameters of type string. One parameter is the original
text string. The other three parameters are used to represent the three data items shown in
the table and are assigned values within the procedure. These values will be used by the
calling program after the procedure ends.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [6]
(ii) Explain the term procedure interface with reference to procedure Unpack().
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
(b) The design changes and a record structure is defined to store the three data items.
TYPE StockItem
DECLARE StockID : STRING
DECLARE Description : STRING
DECLARE Cost : REAL
ENDTYPE
Write the pseudocode statement to assign the value 12.99 to the Cost field of
LineData.
..................................................................................................................................... [1]
(ii) Procedure Unpack() is modified and converted to a function which takes the original
text string as the only parameter.
Explain the other changes that need to be made to convert the procedure into a function.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
(c) Unpack() is part of a program made up of several modules. During the design stage, it is
important to follow good programming practice. One example of good practice is the use of
meaningful identifier names.
Give the reason why this is good practice. Give two other examples of good practice.
Reason .....................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Example 1 .................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Example 2 .................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[3]
(d) The program that includes Unpack() is tested using the walkthrough method.
Describe this method and explain how it can be used to identify an error.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
6 Components are weighed during manufacture. Weights are measured to the nearest whole gram.
Components that weigh at least 3 grams more than the maximum weight, or at least 3 grams less
than the minimum weight, are rejected.
A component is rechecked if it weighs within 2 grams of either the maximum or minimum weight.
Outcome Weight
Reject
Max + 2
Recheck Max Maximum weight
Max – 2
Accept
Min + 2
Recheck Min Minimum weight
Min – 2
Reject
A function Status() will be called with three parameters. These are integers representing the
weight of an individual component together with the minimum and maximum weights.
(a) Complete the following test plan for five tests that could be performed on function Status().
The tests should address all possible outcomes.
5
[5]
© UCLES 2022 9618/23/O/N/22
11
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
Two global 1D arrays are used to store the syntax error data. Both arrays contain 500 elements.
• Array ErrCode contains integer values that represent an error number in the range 1 to 800.
• Array ErrText contains string values that represent an error description.
...
Note:
• There are less than 500 error codes so corresponding elements in both arrays may be
unused. Unused elements in ErrCode have the value 999. These will occur at the end of the
array. The value of unused elements in ErrText is undefined.
• Values in the ErrCode array are stored in ascending order but not all values may be present.
For example, there may be no error code 31.
• Some error numbers are undefined. In these instances, the ErrCode array will contain a
valid error number but the corresponding ErrText element will contain an empty string.
Module Description
• Prompts for input of two error numbers
• Outputs a list of error numbers between the two numbers input
(inclusive) together with the corresponding error description
• Outputs a warning message when the error description is
missing as for error number 50 in the example
• Outputs a suitable header and a final count of error numbers
found
OutputRange()
Output based on the example array data above:
(a) Write pseudocode for module OutputRange(). Assume that the two numbers input
represent a valid error number range.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
© UCLES 2022 9618/23/O/N/22 [Turn over
14
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [8]
Module Description
SortArrays() • Sorts the arrays into ascending order of ErrCode
• Takes two parameters:
• an error number as an integer
• an error description as a string
• Writes the error number and error description to the first
AddError() unused element of the two arrays. Ensures the ErrCode
array is still in ascending order
• Returns the number of unused elements after the new error
number has been added
• Returns −1 if the new error number could not be added
Write pseudocode for the module AddError(). Assume that the error code is not
already in the ErrCode array.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [6]
(ii) A new Module RemoveError() will remove a given error number from the array.
Describe the algorithm that would be required. Do not include pseudocode statements in
your answer.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [3]
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 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.
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 (EF/SG) 338525/4
© UCLES 2023 [Turn over
2
Refer to the insert for the list of pseudocode functions and operators.
(a) Describe how a typical Integrated Development Environment (IDE) could be used to help
debug the program to find the errors in the function Calculate().
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
(b) The algorithm for function Calculate() contains the three pseudocode statements shown.
Describe the error in each statement or write ‘no error’ if the statement contains no error.
Assume any variables used are of the correct type for the given function.
Error ..........................................................................................................................................
...................................................................................................................................................
Error ..........................................................................................................................................
...................................................................................................................................................
Error ..........................................................................................................................................
...................................................................................................................................................
[3]
Variable Value
Active TRUE
Points 75
Exempt FALSE
Expression Evaluation
[2]
(ii) Write expression 4 from the table in part (c)(i) in its simplest form.
..................................................................................................................................... [1]
START
END
[4]
© UCLES 2023 9618/21/M/J/23
5
Write pseudocode statements to declare StartDate and assign to it the date corresponding
to 15/11/2005.
Declaration ...............................................................................................................................
Assignment ...............................................................................................................................
[3]
A program is used to manage the points system and the table lists some of the information stored
for one customer.
(a) (i) Identify a suitable structure for storing the information for one customer. Explain the
advantage of using this structure.
Structure ............................................................................................................................
Advantage .........................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
[4]
(ii) Describe a data structure that could be used to store the information for all customers.
...........................................................................................................................................
..................................................................................................................................... [2]
(b) Customers receive points depending on the amount they spend. The number of points
depends on the band that the amount falls into:
For example, if the amount is $99.77, this amount is in band 2 and therefore the number of
points is 7 × 99, which is 693 points.
The algorithm to calculate the points from a given amount is expressed as follows:
• work out the appropriate band
• calculate and output the number of points.
Apply the process of stepwise refinement to increase the detail of the algorithm. Structure
your algorithm into a sequence of five steps that could be used to produce pseudocode.
1 ................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
3 ................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
4 ................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
5 ................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[5]
© UCLES 2023 9618/21/M/J/23 [Turn over
8
2. form a new string from the original string where all instances of the original character are
replaced by the new character
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [6]
5 Several companies are developing websites to market a new type of games console. The company
that is first to create a website that can demonstrate the interactive features of the games console
will have an advantage over the others. The requirements for the website are likely to change as
more information about the features of the console are made available.
One company has decided to develop their website using a program development life cycle based
on the waterfall model.
(a) (i) Give two reasons why this may not be the most appropriate model to use in this case.
Reason 1 ...........................................................................................................................
...........................................................................................................................................
Reason 2 ...........................................................................................................................
...........................................................................................................................................
[2]
(ii) Identify a more appropriate program development life cycle model for this scenario.
..................................................................................................................................... [1]
(b) The website has been running in test mode for several weeks.
Identify and describe a final stage of testing that should take place before the website is
made available to all customers.
Stage ........................................................................................................................................
Description ................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[3]
6 A video-conferencing program supports up to six users. Speech from each user is sampled and
digitised (converted from analogue to digital). Digitised values are stored in array Sample.
The array Sample consists of 6 rows by 128 columns and is of type integer. Each row contains
128 digitised sound samples from one user.
The digitised sound samples from each user are to be processed to produce a single value which
will be stored in a 1D array Result of type integer. This process will be implemented by procedure
Mix().
Result: 20 20 35 40 46 25
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [6]
7 A school has a computerised library system that allows students to borrow books for a fixed length
of time. The system uses text files to store details of students, books and loans.
A new module is to be written which will generate emails to each student who has an overdue
book.
(a) Decomposition will be used to break down the problem of designing the new module into
sub-problems.
Identify three program modules that could be used in the design and describe their use.
Module 1 ...................................................................................................................................
Use ...........................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Module 2 ...................................................................................................................................
Use ...........................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Module 3 ...................................................................................................................................
Use ...........................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[3]
(b) The program designer produces a structure chart for the new module. Part of the structure
chart is shown:
Module-A()
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
Draw only the part of the structure chart that represents the relationship between
Module‑X(), Module‑Y() and Module‑D().
[3]
© UCLES 2023 9618/21/M/J/23 [Turn over
14
8 A computer shop assembles computers using items bought from several suppliers. A text file
Stock.txt contains information about each item.
Information for each item is stored as a single line in the Stock.txt file in the format:
<ItemNum><SupplierCode><Description>
Format Comment
unique for each item in the range
ItemNum 4 numeric characters
"0001" to "5999" inclusive
The file is organised in ascending order of ItemNum and does not contain all possible values in
the range.
Module Description
SuppExists() • called with a parameter of type string representing a supplier code
(already written)
• returns TRUE if the supplier code is already in use, otherwise returns
FALSE
IsNewSupp() • called with a parameter of type string representing a new supplier code
• returns TRUE if the string only contains alphabetic characters (either
upper or lower case) and the supplier code is not already in use,
otherwise returns FALSE
Module SuppExists() has already been written and should be used as part of your solution.
Module SuppExists() will generate a run-time error if the given parameter is not
5 characters in length.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
Module Description
CheckNewItem() • called with a parameter of type string representing a line of
item information
• checks to see whether an item with the same ItemNum already
exists in the file
• returns TRUE if the ItemNum is not already in the file, otherwise
returns FALSE
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
(c) The program modules SuppExists(), IsNewSupp() and CheckNewItem() are part of a
group of modules that are combined to create a complete stock control program.
Each module in the program is tested individually during development and is debugged as
necessary. It is then added to the program and further testing performed.
..................................................................................................................................... [1]
(ii) One of the modules does not work properly when it is added to the program.
Describe a testing method that can be used to address this problem so that testing can
continue and other modules can be added.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
(d) A new module AddItem() will be used to add information to the Stock.txt file.
State the file mode that should be used for the algorithm within this module.
............................................................................................................................................. [1]
(e) A new module FindItem() searches for a given item in the Stock.txt file, which is already
organised in ascending order of ItemNum.
Describe how this organisation may improve the efficiency of the algorithm.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
© UCLES 2023 9618/21/M/J/23
18
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 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.
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 (EF/SG) 312086/3
© UCLES 2023 [Turn over
2
Refer to the insert for the list of pseudocode functions and operators.
1 A program calculates the postal cost based on the weight of the item and its destination.
Calculations occur at various points in the program and these result in the choice of several
possible postal costs. The programmer has built these postal costs into the program.
For example, the postal cost of $3.75 is used in the following lines of pseudocode:
(a) (i) Identify a more appropriate way of representing the postal costs.
..................................................................................................................................... [1]
(ii) Describe the advantages of your answer to part (a)(i) with reference to this program.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [3]
(b) The lines of pseudocode contain features that make them easier to understand.
1 ................................................................................................................................................
2 ................................................................................................................................................
3 ................................................................................................................................................
[3]
(c) Give the appropriate data types for the following variables:
ValidAddress ........................................................................................................................
ItemPostalCost ...................................................................................................................
ItemStatus ............................................................................................................................
[3]
2 A program stores a user’s date of birth using a variable MyDOB of type DATE.
(a) Write a pseudocode statement, using a function from the insert, to assign the value
corresponding to 17/11/2007 to MyDOB.
............................................................................................................................................. [1]
(b) MyDOB has been assigned a valid value representing the user’s date of birth.
Write a pseudocode statement to calculate the number of months from the month of the
user’s birth until the end of the year and to assign this to the variable NumMonths.
For example, if MyDOB contains a value representing 02/07/2008, the value 5 would be
assigned to NumMonths.
............................................................................................................................................. [2]
(c) The program will output the day of the week corresponding to MyDOB.
For example, given the date 22/06/2023, the program will output "Thursday".
An algorithm is required. An array will be used to store the names of the days of the week.
...................................................................................................................................................
Step 1 .......................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Step 2 .......................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Step 3 .......................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Step 4 .......................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[6]
© UCLES 2023 9618/22/M/J/23 [Turn over
4
3 A program stores data in a text file. When data is read from the file, it is placed in a queue.
(a) The diagram below represents an Abstract Data Type (ADT) implementation of the queue.
Each data item is stored in a separate location in the data structure. During initial design, the
queue is limited to holding a maximum of 10 data items.
0
1
2
3
4
5 Red Front of Queue Pointer
6 Green
7 Blue
8 Pink End of Queue Pointer
9
(i) Describe how the data items Orange and Yellow are added to the queue shown in the
diagram.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [4]
(ii) The following diagram shows the state of the queue after several operations have been
performed. All queue locations have been used at least once.
0 D4
1 D3 End of Queue Pointer
2 D27
3 D8
4 D33
5 D17 Front of Queue Pointer
6 D2
7 D1
8 D45
9 D60
..................................................................................................................................... [1]
(b) The design of the queue is completed and the number of locations is increased.
A function AddToQueue() has been written. It takes a string as a parameter and adds this to
the queue. The function will return TRUE if the string was added successfully.
A procedure FileToQueue() will add each line from the file to the queue. This procedure
will end when all lines have been added or when the queue is full.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [5]
Any comparison between characters needs to be case sensitive. For example, character 'a' and
character 'A' are not identical.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [6]
BLANK PAGE
5 A programmer has produced the following pseudocode to output the square root of the numbers
from 1 to 10.
40 REPEAT
41 CALL DisplaySqrt(Num)
42 Num Num + 1.0
43 UNTIL Num > 10
...
The program code compiles without errors, but the program gives unexpected results. These are
caused by a design error.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
(b) Explain why the compiler does not identify this error.
...................................................................................................................................................
............................................................................................................................................. [1]
(c) Describe how a typical Integrated Development Environment (IDE) could be used to identify
this error.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
(d) The pseudocode is converted into program code as part of a larger program.
The programmer does not want to delete the complex statement but wants to change the
statement so that it is ignored by the compiler.
...................................................................................................................................................
............................................................................................................................................. [1]
6 A procedure Square() will take an integer value in the range 1 to 9 as a parameter and output a
number square.
The boundary of a number square is made up of the character representing the parameter value.
The inside of the number square is made up of the asterisk character (*).
The pseudocode OUTPUT command starts each output on a new line. For example, the following
three OUTPUT statements would result in the outputs as shown:
OUTPUT "Hello"
OUTPUT "ginger"
OUTPUT "cat"
Resulting output:
Hello
ginger
cat
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [6]
BLANK PAGE
7 A computer system for a shop stores information about each customer. The items of information
include name and address (both postal and email) together with payment details and order history.
The system also stores the product categories they are interested in and how they would like to be
contacted.
(a) The shop wants to add a program module that will generate emails to be sent to customers
who may be interested in receiving details of new products.
(i) State three items of information that the new module would need. Justify your choice in
each case.
Information ........................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
Information ........................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
Information ........................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
[3]
(ii) Identify two items of customer information that would not be required by the new module.
Justify your choice in each case.
Information ........................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
Information ........................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
[2]
(b) The program includes a module to validate a Personal Identification Number (PIN). This is
used when customers pay for goods using a bank card.
The table show the inputs, outputs and states for this part of the program:
Complete the state‑transition diagram to represent the information given in the table.
S2
START
S1
Cancel | Re-prompt
[4]
© UCLES 2023 9618/22/M/J/23 [Turn over
16
8 A computer shop assembles computers using items bought from several suppliers. A text file
Stock.txt contains information about each item.
Information for each item is stored as a single line in the Stock.txt file in the format:
<ItemNum><SupplierCode><Description>
Format Comment
unique number for each item in the range
ItemNum 4 numeric characters
″0001″ to ″5999″ inclusive
The file is organised in ascending order of ItemNum and does not contain all possible values in
the range.
Module Description
OnlyAlpha() • called with a parameter of type string
(already written)
• returns TRUE if the string contains only alphabetic characters,
otherwise returns FALSE
CheckInfo() • called with a parameter of type string representing a line of item
information
• checks to see whether the item information in the string is valid
• returns TRUE if the item information is valid, otherwise returns
FALSE
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
Module Description
AddItem() • called with a parameter of type string representing valid information
for a new item that is not currently in the Stock.txt file
• creates a new file NewStock.txt from the contents of the file
Stock.txt and adds the new item information at the appropriate
place in the NewStock.txt file
As a reminder, the file Stock.txt is organised in ascending order of ItemNum and does not
contain all possible values in the range.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
© UCLES 2023 9618/22/M/J/23
19
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
(c) The program contains modules SuppExists() and CheckSupplier(). These have been
written but contain errors. These modules are called from several places in the main program
and testing of the main program (integration testing) has had to stop.
Identify a method that can be used to continue testing the main program before the errors in
these modules have been corrected and describe how this would work.
Method ......................................................................................................................................
Description ................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[3]
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.
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 (PQ/CB) 312089/3
© UCLES 2023 [Turn over
2
Refer to the insert for the list of pseudocode functions and operators.
Answer
The dimension of the array
The name of the variable used as an array index
The number of elements in the array
[3]
(b) The pseudocode contains two errors. One error is that variable PCount has not been
declared.
Identify the other error and state the line number where it occurs.
Error ..........................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [1]
(d) The pseudocode statements given in the following table are used in other parts of the
algorithm.
Complete the table by placing one or more ticks (✓) in each row.
INPUT MyChoice ✓
OUTPUT FirstName & LastName
Result SQRT(NextNum)
[4]
2 A program stores a date of birth for a student using a variable, MyDOB, of type DATE.
(a) MyDOB has been assigned a valid value corresponding to Kevin’s date of birth.
Complete the pseudocode statement to test whether Kevin was born on a Thursday.
(b) A function CheckDate()will take three integer parameters representing a day, month and
year of a given date.
The function will validate the date of birth for a student that the parameters passed to it
represent.
For a date to be valid, a student must be at least 18 in year 2020.
(i) Two of the parameter values can be checked without reference to the third parameter.
Check 1 .............................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
Check 2 .............................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
[2]
(ii) Several values of the parameter representing the day can only be checked completely
by referring to the value of one other parameter.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
BLANK PAGE
3 A program processes data using a stack. The data is copied to a text file before the program ends.
(a) The following diagram shows the current state of the stack.
• The TopOfStack pointer points to the last item added to the stack.
• The BottomOfStack pointer points to the first item on the stack.
• The stack grows upwards when items are added.
Stack Pointer
506
504 YYY
503 XXX
502 ZZZ
501 NNN
(i) An error will be generated if an attempt is made to POP a value when the stack is empty.
State the maximum number of consecutive POP operations that could be performed on
the stack shown above before an error is generated.
..................................................................................................................................... [1]
Complete the diagram to show the state of the stack and the variables after the given
operations have been performed.
Stack Pointer
506
505
504
503
501 Data1
500 Data2
[4]
(b) The data is copied to a text file before the program ends.
(i) State an advantage of writing the data from the stack to a text file before the program
ends.
...........................................................................................................................................
..................................................................................................................................... [1]
(ii) A module SaveStack() will write the data from the stack to a text file.
Express an algorithm for SaveStack() as five steps that could be used to produce
pseudocode.
Step 1 ................................................................................................................................
...........................................................................................................................................
Step 2 ................................................................................................................................
...........................................................................................................................................
Step 3 ................................................................................................................................
...........................................................................................................................................
Step 4 ................................................................................................................................
...........................................................................................................................................
Step 5 ................................................................................................................................
...........................................................................................................................................
[5]
© UCLES 2023 9618/23/M/J/23 [Turn over
8
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [6]
5 A program is designed, coded and compiled without errors. The compiled code is sent for testing.
...................................................................................................................................................
Explanation ...............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[3]
Some time later, changes are made to the program to improve the speed of response.
State the type of maintenance that has been applied to the program.
............................................................................................................................................. [1]
1. take two integer values as parameters representing start and end values where both values
are greater than 9 and the end value is greater than the start value
2. output each integer value between the start and the end value (not including the start and
end values), where the sum of the last two digits is 6, for example, 142.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
© UCLES 2023 9618/23/M/J/23
11
(b) The check performed by procedure Select() on the last two digits is needed at several
places in the program and will be implemented using a new function.
Describe the function interface and two advantages of this modular approach.
Interface ....................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Advantage 1 .............................................................................................................................
...................................................................................................................................................
Advantage 2 .............................................................................................................................
...................................................................................................................................................
[4]
7 A school has a library system which allows students to borrow books for a length of time.
Information relating to students and books is stored in text files. Student information includes
name, home address, email address, date of birth, tutor and subject choices. Book information
includes author, title, subject category, library location and the date that the book was borrowed.
(a) A new module needs to be written to generate emails to send to students who have an
overdue book. Students who are sent an email are prevented from borrowing any more books
until the overdue book is returned.
The process of abstraction has been used when designing the new module.
...........................................................................................................................................
..................................................................................................................................... [1]
(ii) Identify one item of information that is required and one item that is not required in the
new module. Justify your choices.
Justification .......................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
[2]
(iii) Identify two operations that would be required to process data when an overdue book is
returned.
Operation 1 .......................................................................................................................
...........................................................................................................................................
Operation 2 .......................................................................................................................
...........................................................................................................................................
[2]
(b) Part of the library program contains program modules with headers as follows:
[3]
8 A computer shop assembles desktop computers, using items bought from several suppliers. A text
file Stock.txt contains information about each item.
Information for each item is stored as a single line in the Stock.txt file in the format:
<ItemNum><SupplierCode><Description>
Format Comment
unique number for each item in the range “0001”
ItemNum 4 numeric characters
to “5999” inclusive
SupplierCode 3 alphabetic characters code to identify the supplier of the item
The file is organised in ascending order of ItemNum and does not contain all possible values in
the range.
Module Description
ChangeSupp() • called with two parameters Code1 and Code2 of type string that represent
valid supplier codes
• creates a new file NewStock.txt from the contents of the
file Stock.txt where any reference to Code1 is replaced by Code2
• returns a count of the number of items that have had their supplier code
changed
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [8]
Module Description
Report_1() • takes a parameter of type string that represents a SupplierCode
• searches the Stock.txt file for each line of item information that
contains the given SupplierCode
• produces a formatted report of items for the given SupplierCode,
for example, for supplier DRG, the output could be:
Item Description
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
(c) The format of the output from module Report_1() from part (b) is changed. The number of
items listed is moved to the top of the report as shown in the example:
Item Description
(i) Explain why this new layout would increase the complexity of the algorithm.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
(ii) The algorithm will be modified to produce the report in the new format. The modified
algorithm will be implemented so that the file Stock.txt is only read once.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [3]
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 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.
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 (LK/SG) 315866/3
© UCLES 2023 [Turn over
2
Refer to the insert for the list of pseudocode functions and operators.
CASE OF ThisValue
< 30 : Level "Low" ←
// less than 30
Check 1 ←
< 20 : Level "Very Low" ←
// less than 20
Check ThisValue / 2 ←
30 TO 40 : Level "Medium" ←
// between 30 and 40
Check ThisValue / 3 ←
Data[ThisValue] Data[ThisValue] + 1 ←
> 40 : Level "High" ←
ENDCASE
(a) Complete the table by writing the answer for each row:
Answer
(b) The pseudocode contains four assignments to variable Level. One of these assignments
will never be performed.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
(c) The following line is added immediately before the ENDCASE statement:
...................................................................................................................................................
............................................................................................................................................. [1]
(d) Give the appropriate data types for the variables ThisValue, Check and Level.
ThisValue ..............................................................................................................................
Check .......................................................................................................................................
Level ......................................................................................................................................
[3]
Outline, using stepwise refinement, the five steps for this algorithm which could be used to
produce pseudocode.
Step 1 .......................................................................................................................................
...................................................................................................................................................
Step 2 .......................................................................................................................................
...................................................................................................................................................
Step 3 .......................................................................................................................................
...................................................................................................................................................
Step 4 .......................................................................................................................................
...................................................................................................................................................
Step 5 .......................................................................................................................................
...................................................................................................................................................
[5]
Identify two other programming constructs that will be required when the algorithm is
converted into pseudocode.
Construct 1 ...............................................................................................................................
...................................................................................................................................................
Construct 2 ...............................................................................................................................
...................................................................................................................................................
[2]
• The TopOfStack pointer points to the last item added to the stack.
• The BottomOfStack pointer points to the first item on the stack.
Stack
D1 ← TopOfStack
D3
D4
D5
D2 ← BottomOfStack
(a) The stack is implemented using two variables and a 1D array of 8 elements as shown.
The variables are used to reference individual elements of the array, in such a way that:
• the array is filled from the lowest indexed element towards the highest
• all the elements of the array are available for the stack.
Complete the diagram to represent the state of the stack as shown above.
Array Data
element
8
5 Variable
4 TopOfStack
3 BottomOfStack
1
[3]
(b) A function Push() will add a value onto the stack by manipulating the array and variables in
part (a).
Before adding a value onto the stack, the algorithm will check that space is available.
If the value is added to the stack, the function will return TRUE, otherwise it will return FALSE.
5. Return .............................. .
[5]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
(b) The global array is changed to a 2D array, organised as 150 rows by 2 columns. It is declared
in pseudocode as follows:
The algorithm for the function in part (a) is changed. Strings will only be counted if both of
the following conditions are true:
Assume that the row index is contained in variable Row and the search string in variable
Search.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
5 An algorithm is designed to find the smallest numeric value from an input sequence and count
how many numeric values have been input.
An example of an input sequence is:
Numeric input values are all integers and non-numeric input is ignored, except for the string "END"
which is used to terminate the sequence.
Min ← 999
Count ←0
REPEAT
INPUT NextInput
IF IS_NUM(NextInput) = TRUE THEN
Num ←
STR_TO_NUM(NextInput)
IF Num > Min THEN
Min Num ←
ENDIF
Count ←
Count & 1
ENDIF
UNTIL NextInput "END" ←
OUTPUT "The minimum value is ", Min, " and the count was ", Count
(a) The pseudocode contains three errors due to the incorrect use of operators.
1 ................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
...................................................................................................................................................
3 ................................................................................................................................................
...................................................................................................................................................
[3]
(b) The operator errors are corrected and the algorithm is tested as follows:
The algorithm is tested with a different test data sequence. The sequence contains a mix
of integer and non-numeric values. It is terminated correctly but the algorithm produces
unexpected results.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
(ii) Give a sequence of four test data values that could be input to demonstrate the problem.
Value 1 ..............................................................................................................................
Value 2 ..............................................................................................................................
Value 3 ..............................................................................................................................
Value 4 ..............................................................................................................................
[2]
(a) A new procedure MyOutput() will take a string and a Boolean parameter.
MyOutput() may be called repeatedly and will use concatenation to build a string using a
global variable MyString, up to a maximum length of 255 characters.
For example, the calls to MyOutput() given below would result in the output as shown:
Resulting output:
Notes:
• MyString is initialised to an empty string before MyOutput() is called for the first time.
• No string passed to MyOutput() will be longer than 255 characters.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
(b) The design of the procedure given in part (a) is modified and MyString is changed from a
global to a local variable declared in MyOutput().
When the modified procedure is converted into program code, it does not work as expected.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]
The table shows the inputs, outputs and states for the algorithm:
Complete the state-transition diagram to represent the information given in the table.
A1 | X1
START
S1
A3
[5]
BLANK PAGE
8 A class of students are developing a program to send data between computers. Many computers
are connected together to form a wired network. Serial ports are used to connect one computer to
another.
Each computer:
Messages are sent between computers as a string of characters organised into fields as shown:
<STX><DestinationID><SourceID><Data><ETX>
Field
Field name Description
number
a single character marking the start of the message
n/a STX
(ASCII value 02)
1 DestinationID three numeric characters that identify the destination computer
For example, the following message contains the data "Hello Kevin" being sent from computer
"101" to computer "232":
<STX>"232101Hello Kevin"<ETX>
Each computer will run a copy of the same program. Each program will contain a global variable,
MyID of type string, that contains the unique ID of the computer in which the program is running.
The programmer has defined the first two program modules as follows:
Module Description
• takes two parameters:
Transmit() o a string containing a message
(already written) o an integer containing a port number
• transmits the message using the given port
• takes three parameters:
o a string containing a text file name
SendFile() o a string containing a Destination ID
o an integer containing a Port number
• transmits the file one line at a time
• transmits a final message with data string "****"
Assume:
• module Transmit() has already been written and is used to transmit a message
• the value of MyID may be used as SourceID
• the file specified contains no blank lines
• the file specified does not contain the line "****"
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
(b) Module SendFile() is used to copy a file from one computer to another.
A module within the program running on the destination computer will receive the data and
write it to a new file.
Explain why module SendFile() transmits the message with data string "****" after the
last line of the file.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]
(c) One of the text files to be sent contains several blank lines (lines that do not contain any text).
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
(ii) Explain how the message format could be changed to allow a blank line to be sent.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
BLANK PAGE
Module Description
• takes two parameters:
o a string containing a message
GetField() o an integer containing a field number
• If the field number is valid (in the range 1 to 3, inclusive), it
returns a string containing the required field, otherwise it returns
an empty string.
<STX><DestinationID><SourceID><Data><ETX>
Field
Field name Description
number
a single character marking the start of the message
Not applicable STX
(ASCII value 02)
1 DestinationID three numeric characters that identify the destination computer
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
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.
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 (LK/SG) 315868/1
© UCLES 2023 [Turn over
2
Refer to the insert for the list of pseudocode functions and operators.
1 A shop sells car accessories. A customer order is created if an item cannot be supplied from
current stock. A program is being developed to create and manage the customer orders.
(a) The following identifier table shows some of the data that will be stored for each order.
Complete the identifier table by adding meaningful variable names and appropriate data
types.
Example
Explanation Variable name Data type
value
[4]
Complete the table by evaluating each expression using the example values.
Expression Evaluates to
RIGHT(Description, 7)
(LENGTH(Description) - 8) > 16
(c) The data that needs to be stored for each customer order in part (a) is not all of the same
type.
Describe an effective way of storing this data for many customer orders while the program is
running.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
2 An algorithm will:
START
END
[5]
Name ........................................................................................................................................
Justification ...............................................................................................................................
...................................................................................................................................................
[2]
Ptr1
D40 D32 D11 D100 Ø
Ptr2
F1 F2 F3 F4 Ø
(a) The linked list is implemented using two variables and two 1D arrays as shown.
The pointer variables and the elements of the Pointer array store the indices (index numbers)
of elements in the Data array.
Complete the diagram to show how the linked list as shown above may be represented using
the variables and arrays.
Variable Value
Start_Pointer
Free_List_Pointer 5
2 3
4 D40
6 F2 7
8
[5]
(b) The original linked list is to be modified. A new node D6 is inserted between nodes D32 and
D11.
Ptr1
D40 D32 D11 D100 Ø
Ptr2
F1 F2 F3 F4 Ø
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
Typical test data would consist of odd and even values, for example:
The purpose of this test would be to test a typical mix of even and odd values and check the
totals.
Give three test data sequences that may be used to test different aspects of the procedure.
Sequence 1:
...................................................................................................................................................
Sequence 2:
...................................................................................................................................................
Sequence 3:
...................................................................................................................................................
[3]
5 A global 1D array of integers contains four elements, which are assigned values as shown:
Mix[1] ←1
Mix[2] ←3
Mix[3] ←4
Mix[4] ←2
A procedure Process() manipulates the values in the array.
Index ← Start
Count ←0
REPEAT
Value ←Mix[Index]
Mix[Index]← Mix[Index] - 1
Index ←Value
Count ←Count + 1
UNTIL Count = 5
Complete the trace table on the opposite page by dry running the procedure when it is called as
follows:
CALL Process(3)
[6]
Each file is given a different name. Each file name is formed by concatenating the file name
with a suffix based on the file number. The suffix is always three characters.
For example, the call CreateFiles("TestData", 3) would result in the creation of the
three files, TestData.001, TestData.002 and TestData.003.
Each file will contain a single line. For example, file TestData.002 would contain the string:
Assume both parameters are valid and that the integer value is between 1 and 999, inclusive.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
© UCLES 2023 9618/22/O/N/23
13
(b) A module CheckFiles() will count the number of files produced by CreateFiles() in
part (a).
CheckFiles() will take a string representing a file name and return the number of files
found.
(i) Identify the type of module that should be used for CheckFiles().
..................................................................................................................................... [1]
...........................................................................................................................................
..................................................................................................................................... [1]
..................................................................................................................................... [1]
Module-A()
[4]
(b) Explain the meaning of the diamond symbol as used in the diagram in part (a).
...................................................................................................................................................
............................................................................................................................................. [2]
BLANK PAGE
8 A class of students are developing a program to send data between computers. Many computers
are connected together to form a wired network. Serial ports are used to connect one computer to
another.
Each computer:
<DestinationID><Data>
Messages may pass through several computers on the way to their destination.
When a message arrives at a computer, that is not the destination, the program needs to forward
it on to another computer using one of its serial ports.
The port to use is obtained from information that is stored in an array RouteTable.
The values in the first two columns of RouteTable define a range of ID values.
Column 3 gives the corresponding port number to use when forwarding the message to a computer
with an ID within this range.
In this example, a message that arrives with a DestinationID of "283" will be forwarded using
port 2.
Row 3 in the example shows an unused row. These may occur anywhere. Unused rows have the
column 1 element set to −1. The value of unused elements in the other two columns is undefined.
Module Description
• takes a DestinationID as a parameter of type string
• searches for the range corresponding to the DestinationID
GetPort() in the array
• returns the port number, or returns −1 if no corresponding
range is found
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
© UCLES 2023 9618/22/O/N/23 [Turn over
18
(b) Copies of the same program will run on each computer. The program contains a global
variable MyID of type string, which contains the unique ID of the computer in which the
program is running.
When messages are received, they are placed on one of two stacks. Stack 1 is used for
messages that have reached their destination and stack 2 is used for messages that will be
forwarded on to another computer.
Module Description
• takes two parameters:
○ a string representing a message
StackMsg() ○ an integer representing the stack number
(already written) • adds the message to the required stack
• returns TRUE if the message is added to the required stack,
otherwise returns FALSE
• takes a message as a parameter of type string
• ignores any message with a zero-length data field
• extract the DestinationID from the message
• checks whether the DestinationID is this computer or
ProcessMsg() whether the message is to be forwarded
• uses StackMsg() to add the message to the appropriate
stack
• outputs an error if the message could not be added to the
stack
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
(c) The program contains a module GetFile() which receives text files sent from another
computer.
Lines from the file are sent one at a time. Each message contains one line and ProcessMsg()
from part (b) adds each message as it is received onto stack 1.
Module GetFile() removes messages from stack 1 and writes the data to a text file.
There is a problem. Under certain circumstances, the received file does not appear as
expected.
Assume that while a file is being received ProcessMsg() receives only messages containing
lines from the file.
Circumstances ..................................................................................................................
...........................................................................................................................................
Explanation .......................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
[3]
(ii) Suggest a more appropriate Abstract Data Type that could be used to store the messages
that would not have the same problem.
..................................................................................................................................... [1]
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.
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 (LK/CT) 315870/2
© UCLES 2023 [Turn over
2
Refer to the insert for the list of pseudocode functions and operators.
(a) The following table shows four valid pseudocode assignment statements.
Complete the table by giving the data type that should be used to declare the variable
underlined in each assignment statement.
Variable Value
Active TRUE
Fraction 0.2
Code "Ab12345"
Complete the table by evaluating each expression using the example values.
Expression Evaluates to
STR_TO_NUM(MID(Code, 4, 2)) + 5
(c) The program makes use of complex statistical functions. The required functions are not
built-in to the programming language and are too complicated for the programmer to write.
One solution would be to employ another programmer who has experience of writing these
functions, as there is no time to train the existing programmer.
State one other way that these functions may be provided for inclusion in the program.
...................................................................................................................................................
............................................................................................................................................. [1]
(d) The hardware that runs the program is changed and the program needs to be modified so
that it works with the new hardware.
Identify the type of maintenance that this represents and give one other reason why this type
of maintenance may be needed.
Type ..........................................................................................................................................
Reason .....................................................................................................................................
...................................................................................................................................................
[2]
2 Data is a 1D array of integers, containing 30 elements. All element values are unique.
(a) An algorithm will output the index of the element with the smallest value.
START
END
[5]
(b) The 30 data values could have been stored in separate variables rather than in an array.
Explain the benefits of using an array when designing a solution to part (a).
...................................................................................................................................................
............................................................................................................................................. [2]
(c) The requirement changes. Array Data needs to hold 120 elements and each value may
include a decimal place.
...................................................................................................................................................
............................................................................................................................................. [2]
Queue
D3 ← FrontOfQueue
D4
D1
D2
D5 ← EndOfQueue
The queue is implemented using three variables and a 1D array of eight elements as shown. The
variable NumItems stores the number of items in the queue.
(a) Complete the diagram to represent the state of the queue as shown above.
Index Array
4 Variable
5 FrontOfQueue
6 EndOfQueue
7 NumItems 5
8
[3]
(b) A module AddTo() will add a value to the queue by manipulating the array and variables in
part (a).
The queue implementation is circular. When pointers reach the end of the queue, they will
‘wrap around’ to the beginning.
Before a value can be added to the queue, it is necessary to check the queue is not full.
2. Increment ................................... .
4. Increment ................................... .
6. Stop.
[6]
4 A procedure RandList() will output a sequence of 25 random integers, where each integer is
larger than the previous one.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
(b) Procedure RandList() is modified so that the random numbers are also written into a
1D array Result.
A new module is written to confirm that the numbers in the array are in ascending order.
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [1]
5 A global 1D array of integers contains four elements, which are assigned values as shown:
Mix[1] ←4
Mix[2] ←2
Mix[3] ←3
Mix[4] ←5
A procedure Process() manipulates the values in the array.
Index ← Start
Total ←0
WHILE Total < 20
Value ←Mix[Index]
Total ←Total + Value
ENDWHILE
Complete the trace table on the opposite page by dry running the procedure when it is called as
follows:
CALL Process(2)
[6]
The function will test whether the string meets certain conditions and will return an integer value
as follows:
The function will return the highest possible value for the given string.
If the string does not meet any of the conditions, zero is returned.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [6]
Module-A()
T1 RA
SA
RB
(a) Explain the meaning of the curved arrow symbol which begins and ends at Module-A().
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]
A record type MyType will be defined with three fields to store the values passed between the
two modules.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [3]
...........................................................................................................................................
..................................................................................................................................... [2]
8 A class of students are developing a program to send data between computers. Many computers
are connected together to form a wired network. Serial ports are used to connect one computer to
another.
Each computer:
• is assigned a unique three-digit ID
• has three ports, each identified by an integer value
• is connected to between one and three other computers.
Messages are sent between computers as a string of characters organised into fields as shown:
<STX><DestinationID><SourceID><Data><ETX>
For example, the following message contains the data "Hello Jack" being sent from computer
"202" to computer "454":
<STX>"454202Hello Jack"<ETX>
Each computer will run a copy of the same program. Each program will contain a global variable
MyID of type string which contains the unique ID of the computer in which the program is running.
Module Description
GetData()
• returns the data field from a message that has been received
(already written)
• If no message is available, the module waits until one has been
received.
• takes a file name as a parameter of type string
• creates a text file with the given file name (no checking required)
ReceiveFile()
• writes the data field returned by GetData() to the file
• repeats until the data field is "****", which is not written to the file
• outputs a final message giving the total number of characters
written to the file, for example:
132456 characters were written to newfile.txt
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
(b) The use of the string "****" as explained in the module description for ReceiveFile() may
cause a problem.
Problem ....................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Solution .....................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[3]
(c) Two new modules are defined, which will allow two users to exchange messages.
Module Description
Reminders:
• Each program contains a global variable MyID of type string which contains the unique ID of
the computer in which the program is running.
• Messages are sent between computers as a string of characters organised into fields as
shown:
<STX><DestinationID><SourceID><Data><ETX>
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [7]
(d) Module GetData() returns the data field from a message that has been received. If no
message is available, the module waits until one has been received.
Limitation ..................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Modification ..............................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[3]
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.
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 (PQ/CGW) 329348/4
© UCLES 2024 [Turn over
2
Refer to the insert for the list of pseudocode functions and operators.
(a) The following table shows four valid pseudocode assignment statements.
Complete the table by giving an appropriate data type to declare each of the variables A, B, C
and D.
Variable Value
Sorted False
Tries 9
ID "ZGAC001"
Complete the table by evaluating each expression, using the example values.
Expression Evaluates to
Tries MOD 4
TO_LOWER(MID(ID, 3, 1))
(c) The variable names A, B, C and D in part (a) are not good programming practice.
...........................................................................................................................................
..................................................................................................................................... [1]
(ii) Identify one problem that these variable names might cause.
...........................................................................................................................................
..................................................................................................................................... [1]
(iii) The choice of suitable variable names is one example of good programming practice.
...........................................................................................................................................
..................................................................................................................................... [1]
START
INPUT A, B
Yes
No
END
[5]
© UCLES 2024 9618/21/M/J/24
5
Following the input of ThisSequence the revised algorithm will extract the pairs of numbers.
Describe the variable ThisSequence and how the numbers are extracted.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]
3 The diagram shows an Abstract Data Type (ADT) representation of a linked list after data items
have been added.
PS
Df Dc Db Dy Ø
PF
Fg Fh Fm Fw Ø
(a) Describe the linked list immediately after initialisation, before any data items are added.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [3]
(b) A program will be written to include a linked list to store alphanumeric user IDs.
The design uses two variables and two 1D arrays to implement the linked list.
Each array element contains data of a single data type and not a record.
................................................................................................................................................. .
• total the element values in odd index locations (1, 3, 5 ... 97, 99)
• total the element values in even index locations (2, 4, 6 ... 98, 100)
• return one of three strings ‘Odd’, ‘Even’ or ‘Same’ to indicate which total is the greater, or
whether the totals are the same.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [6]
BLANK PAGE
5 A global 1D array of strings contains three elements which are assigned values as shown:
Data[1] "aaaaaa"
Data[2] "bbbbbb"
Data[3] "cccccc"
Result "****"
CASE OF C
'X' : Result TO_UPPER(Data[Index])
'Y' : Result TO_LOWER(Data[Index])
'Z' : Result "**" & Data[Index]
ENDCASE
Data[Index] LEFT(Result, L)
NEXT Count
ENDPROCEDURE
(a) Complete the trace table by dry running the procedure when it is called as follows:
CALL Process("X3Y2W4")
[6]
(b) The procedure is to be modified. If variable C is assigned a value other than 'X', 'Y' or 'Z',
then procedure Error() is called and passed the value of variable C as a parameter.
..................................................................................................................................... [1]
..................................................................................................................................... [1]
6 Three points on a grid form a triangle with sides of length A, B and C as shown in the example:
10
9
8
7
6
5 B C
4
3
2 A
1
x
0 1 2 3 4 5 6 7 8 9 10
A triangle is said to be right-angled if the following test is true (where A is the length of the longest
side):
A2 = B2 + C2
You can calculate A2, B2 and C2 by using the coordinates of the endpoints of each line.
10
9
8
7
P2
6 (x2, y2)
5 B
4
3
P1
2 (x1, y1)
1
x
0 1 2 3 4 5 6 7 8 9 10
The endpoints, P1 and P2, have the coordinates (3, 2) and (6, 6).
In this example:
B2 = (3 − 6)2 + (2 − 6)2
B2 = (–3)2 + (–4)2
B2 = 9 + 16
B2 = 25
• take three sets of integers as parameters representing the coordinates of the three
endpoints that form a triangle
• return TRUE if the endpoints form a right-angled triangle, otherwise return FALSE.
In pseudocode, the operator ‘^’ represents an exponent, which is the number of times a value
is multiplied by itself. For example, the expression Value2 may be written in pseudocode as
Value ^ 2
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
ENDFUNCTION
[6]
(b) The test used to check if a triangle is right-angled can be written in two ways:
A2 = B2 + C2
or
A = √(B2 + C2)
The symbol √ represents the square root operation. For example, √81 = 9
A new function SQRT() is written to perform the square root operation. The function takes an
integer number as a parameter and returns a positive real value representing the square root
of the number.
During testing it is found that the SQRT() function returns a value that is only accurate to
4 decimal places.
For example, SQRT(25) returns 5.0000125 rather than the correct value of 5.0
The function IsRA() from part (a) is modified to use the new SQRT() function to test if a
triangle is right-angled.
Describe a problem that might occur when using the modified IsRA() function and suggest
a solution that still allows the SQRT() function to be used.
Problem ....................................................................................................................................
...................................................................................................................................................
Solution .....................................................................................................................................
...................................................................................................................................................
[2]
BLANK PAGE
7 A fitness club has a computerised membership system. The fitness club offers a number of
different exercise classes.
The following information is stored for each club member: name, home address, email address,
mobile phone number, date of birth and the exercise(s) they are interested in.
(a) When an exercise class is planned, a new module will send personalised text messages to
each member who has expressed an interest in that exercise. Members wishing to join the
class send a text message back. Members may decide not to receive future text messages
by replying with the message ‘STOP’.
...........................................................................................................................................
..................................................................................................................................... [1]
(ii) Identify three items of information that will be required by the new module.
Justify your choices with reference to the given scenario.
Justification .......................................................................................................................
...........................................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
Justification .......................................................................................................................
...........................................................................................................................................
[3]
(iii) Identify two operations that would be required to process data when the new module
receives a text message back from a member.
Operation 1 .......................................................................................................................
...........................................................................................................................................
Operation 2 .......................................................................................................................
...........................................................................................................................................
[2]
Update
A
P2
T1
Name P1
(i) Explain the meaning of the diamond symbol (labelled with the letter A) in the chart.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
(ii) Write the pseudocode module headers for Sub-A and Sub-B.
Sub-A
...........................................................................................................................................
...........................................................................................................................................
Sub-B
...........................................................................................................................................
...........................................................................................................................................
[4]
The process is split into a number of stages. Each stage performs a different task and creates a
new file named as shown:
Module Description
DeleteComment() • called with a parameter of type string representing a line of
pseudocode from a student’s project file
• returns the line after removing any comments
Note on comments:
A comment starts with two forward slash characters and includes all the
remaining characters on the line.
The following example shows a string before and after the comment has
been removed:
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
ENDFUNCTION
[8]
Module Description
Stage_1() • called with a parameter of type string representing a student name
• creates a new stage 1 file
• copies each line from the student’s project file to the stage 1 file after
removing any comment from each line
• does not write blank lines to the stage 1 file
• returns the number of lines written to the stage 1 file
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
© UCLES 2024 9618/21/M/J/24
21
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
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 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.
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 (PQ/CGW) 329350/3
© UCLES 2024 [Turn over
2
Refer to the insert for the list of pseudocode functions and operators.
Each example may contain statements that relate to one or more of the following:
• selection
• iteration (repetition)
• input/output.
Complete the table by placing one or more ticks (3) in each row.
MyChar CHAR
MyString STRING
MyInt INTEGER
Complete the table by filling in each gap with a function (from the insert) so that each expression
is valid.
Expression
(c) The variables given in part (b) are chosen during the design stage of the program development
life cycle.
State a suitable way of documenting the variables and give one piece of information that
should be recorded, in addition to the data type.
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [2]
Assume the values are all different and are input in no particular order.
START
No
Yes
END
[5]
(b) A different part of the program contains an algorithm represented by the following program
flowchart:
START
Is Flag = Yes
TRUE ?
No END
Set Port to 1
No
Is Port = 4 ?
CALL Reset(Port)
Yes
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [5]
© UCLES 2024 9618/22/M/J/24
7
The data for each item will be held in a record structure of type Component.
The programmer has started to define the fields that will be needed as shown in the table.
(a) (i) Write pseudocode to declare the record structure for type Component.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [4]
(ii) A 1D array Item of 2000 elements will store the data for all items.
...........................................................................................................................................
..................................................................................................................................... [2]
(b) State three benefits of using an array of records to store the data for all items.
1 ................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
...................................................................................................................................................
3 ................................................................................................................................................
...................................................................................................................................................
[3]
© UCLES 2024 9618/22/M/J/24 [Turn over
8
B C
A × A = (B × B) + (C × C)
A procedure will be written to check whether three lengths represent a right‑angled triangle.
The lengths will be input in any sequence.
The length of the longest side may not be the first value input.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
.................................................................................................................................................... [5]
The program contains a global 1D array Data of type string containing 200 elements.
(a) (i) The pseudocode contains two syntax errors and one other error.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
[3]
Statement ..........................................................................................................................
Explanation .......................................................................................................................
...........................................................................................................................................
[2]
(b) After correcting all syntax errors, the pseudocode is translated into program code which
compiles without generating any errors.
............................................................................................................................................. [1]
6 A music player stores music in a digital form and has a display which shows the track being
played.
(a) Up to 16 characters can be displayed. Track titles longer than 16 characters will need to be
trimmed as follows:
• Words must be removed from the end of the track title until the resulting title is less than
14 characters.
• When a word is removed, the space in front of that word is also removed.
• Three dots are added to the end of the last word displayed when one or more words
have been removed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Bohemian Symphony B o h e m i a n . . .
Paperbook Writer P a p e r b o o k W r i t e r
Assume:
• Words in the original title are separated by a single space character.
• There are no spaces before the first word or after the last word of the original title.
• The first word of the original title is less than 14 characters.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
The samples are to be stored in a text file. Each sample is converted to a numeric string and
32 samples are concatenated (joined) to form a single line of the text file.
Each numeric string is 8 characters in length; leading ‘0’ characters are added as required.
Example:
32 673 "00000673"
The example samples will be stored in the text file as a single line:
"000004560000004800037652...00000673"
(i) Identify one drawback of adding leading ‘0’ characters to each numeric string.
...........................................................................................................................................
..................................................................................................................................... [1]
(ii) Suggest an alternative method of storing the samples which does not involve adding
leading ‘0’ characters but which would still allow each individual sample to be extracted.
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [1]
(iii) State one drawback of the alternative method given in part (b)(ii).
...........................................................................................................................................
..................................................................................................................................... [1]
BLANK PAGE
The system stores information for each club member: name, home address, email address, mobile
phone number, date of birth and exercise preferences.
Many classes are full, and the club creates a waiting list for each class. The club adds details of
members who want to join a class that is full to the waiting list for that class.
When the system identifies that a space is available in one of the classes, a new module will send
a text message to each member who is on the waiting list.
(a) Decomposition will be used to break the new module into sub‑modules (sub‑problems).
Identify three sub‑modules that could be used in the design and describe their use.
Sub‑module 1 ...........................................................................................................................
Use ...........................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Sub‑module 2 ...........................................................................................................................
Use ...........................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Sub‑module 3 ...........................................................................................................................
Use ...........................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
[3]
(b) A different part of the program is represented by the following state‑transition diagram.
Input-B | Output-W
Input-B
Input-B
START
S1 S3 S2 S5
Input-A
Input-A Input-A | Output-W
Input-B | Output-Y
Input-A | Output-X
S4
(i) Complete the table to show the inputs, outputs and next states.
Assume that the current state for each row is given by the ‘Next state’ on the previous
row. For example, the first Input‑A is made when in state S1.
If there is no output for a given transition, then the output cell should contain ‘none’.
S1
Input‑A none S3
Output‑W
none
Input‑B
Input‑A
S4
[5]
(ii) Identify the input sequence that will cause the minimum number of state changes in the
transition from S1 to S4.
..................................................................................................................................... [1]
The process is split into a number of stages. Each stage performs a different task and creates a
new file.
For example:
(a) Suggest a reason why the teacher’s program has been split into a number of stages and give
the benefit of producing a different file from each stage.
Reason .....................................................................................................................................
...................................................................................................................................................
Benefit ......................................................................................................................................
...................................................................................................................................................
[2]
(b) The teacher has defined the first program module as follows:
Module Description
DeleteSpaces() • called with a parameter of type string representing a line of
pseudocode from a student’s project file
• returns the line after removing any leading space characters
The following example shows a string before and after the leading
spaces have been removed:
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
ENDFUNCTION [6]
Module Description
DeleteComment() • called with a parameter of type string representing a line of
(already written) pseudocode from a student’s project file
• returns the line after removing any comment
Stage_2() • called with two parameters:
○ a string representing an input file name
○ a string representing an output file name
• copies each line from the input file to the existing output file having
first removed all leading spaces and comments from that line
• does not write blank lines to the output file
• outputs a final message giving the number of blank lines removed
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [8]
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 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.
¬O> 3mGwMq=5uUpW
¬bD§43Pt|¤P\M
¥u¥U5U¥5UEUeEeEU
* 6 8 0 6 8 0 7 8 2 2 *
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 (KS/CGW) 329352/4
© UCLES 2024 [Turn over
* 0019655333802 *
Refer to the insert for the list of pseudocode functions and operators.
One algorithm is repeated in several places. The code for the algorithm is the same wherever it is
used, but the calculations within the algorithm may operate on different data.
The result of each calculation is used by the code that follows it.
It is decided to modify the program and implement the algorithm as a separate module.
1 ........................................................................................................................................
...........................................................................................................................................
2 ........................................................................................................................................
...........................................................................................................................................
[2]
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [3]
DO NOT WRITE IN THIS MARGIN
ĬÍĊ¾Ġ³íÇ÷Íñ½Ğ¸÷×î×
© UCLES 2024 ĬĖĜáÁģ¸ÕçýþģÜõĠĤÕĂ
ĥåõÕõµåÕĥąąÕåÕåĥĥÕ
9618/23/M/J/24
* 0019655333803 *
DO NOT WRITE IN THIS MARGIN
3
, ,
(b) Four of the expressions used in the program are represented by pseudocode in the table.
Complete each pseudocode expression with a function or operator so that it evaluates to the
value shown.
"and"
DO NOT WRITE IN THIS MARGIN
........................................ ("Random", 2, 3)
15
5 + ........................................ (10/11/2023)
TRUE
........................................ ("45000")
(20 ........................................ 3) + 1 3
[4]
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
ĬÏĊ¾Ġ³íÇ÷Íñ½Ğ¸õ×î×
© UCLES 2024 ĬĖěâÉĥ¼åÒûóæĀý¼ĤåĂ
ĥåąĕµÕŵõõÕÕåµÅåõÕ
9618/23/M/J/24 [Turn over
* 0019655333804 *
2 (a) A program uses a global 1D array of type string and a text file.
Outline five steps for this algorithm that could be used to produce pseudocode.
Step 1 .......................................................................................................................................
...................................................................................................................................................
Step 2 .......................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
Step 4 .......................................................................................................................................
...................................................................................................................................................
Step 5 .......................................................................................................................................
...................................................................................................................................................
[5]
Identify one other programming construct that will be required when the algorithm from
part (a) is converted into pseudocode and explain its use.
Construct ..................................................................................................................................
...................................................................................................................................................
Use ...........................................................................................................................................
...................................................................................................................................................
[2]
DO NOT WRITE IN THIS MARGIN
ĬÍĊ¾Ġ³íÇ÷Íñ½Ğ¶÷×ð×
© UCLES 2024 ĬĖěãÉğÊäåõüÝÞáĚôÍĂ
ĥĕÕĕõÕÅĕĕÕåÕĥµĥåĥÕ
9618/23/M/J/24
DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN
,
© UCLES 2024
* 0019655333805 *
ĥĕåÕµµåõąåõÕĥÕąĥõÕ
ĬĖĜäÁĩÆÔÔăąĬúÙ¾ôÝĂ
ĬÏĊ¾Ġ³íÇ÷Íñ½Ğ¶õ×ð×
,
5
9618/23/M/J/24
BLANK PAGE
[Turn over
* 0019655333806 *
3 A record structure is declared to hold data relating to components being produced in a factory:
TYPE Component
DECLARE Item_ID : STRING
DECLARE Reject : BOOLEAN
DECLARE Weight : REAL
ENDTYPE
The factory normally produces a batch (or set) of 1000 components at a time. A global array is
declared to store 1000 records for a batch:
Two global variables contain the minimum and maximum acceptable weight for each component.
The values represent an inclusive range and are declared as:
(a) (i) A program uses a variable ThisIndex as the array index to access a record.
Write a pseudocode clause to check whether or not the weight of an individual component
is within the acceptable range.
...........................................................................................................................................
..................................................................................................................................... [3]
(ii) When batches of less than 1000 components are processed, it is necessary to indicate
that certain elements in the array are unused.
...........................................................................................................................................
components exceeds 5.
ĬÑĊ¾Ġ³íÇ÷Íñ½Ğ·õÖî×
© UCLES 2024 ĬĖěä¾ģÞÚÜĈøđĚáßÜÍĂ
ĥÅąÕµĕåÕÅÅÕÕåÕåååÕ
9618/23/M/J/24
* 0019655333807 *
DO NOT WRITE IN THIS MARGIN
7
, ,
Complete the program flowchart to represent the algorithm for module BatchCheck().
START
DO NOT WRITE IN THIS MARGIN
Is
Index = 1001 ?
DO NOT WRITE IN THIS MARGIN
Yes
No
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
END
[5]
ĬÓĊ¾Ġ³íÇ÷Íñ½Ğ·÷Öî×
© UCLES 2024 ĬĖĜãÆĥâêÝòĉؾÙûÜÝĂ
ĥÅõĕõõŵյąÕåµÅĥµÕ
9618/23/M/J/24 [Turn over
* 0019655333808 *
Values input in the first part are totalled using global variable TotalA and those input in the
second part are totalled using global variable TotalB.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [6]
ĬÑĊ¾Ġ³íÇ÷Íñ½ĞµõÖð×
© UCLES 2024 ĬĖĜâÆğÔßÚðĂÏĠõÙÌÕĂ
ĥõåĕµõÅĕµĕõÕĥµĥĥåÕ
9618/23/M/J/24
* 0019655333809 *
DO NOT WRITE IN THIS MARGIN
9
, ,
(b) The value zero denotes the split between the two parts of the sequence.
(i) Identify a suitable data structure that could be used to store the different total values.
..................................................................................................................................... [2]
(ii) Describe three benefits of using the data structure given in part (b)(i).
1 ........................................................................................................................................
DO NOT WRITE IN THIS MARGIN
...........................................................................................................................................
2 ........................................................................................................................................
...........................................................................................................................................
3 ........................................................................................................................................
...........................................................................................................................................
[3]
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
ĬÓĊ¾Ġ³íÇ÷Íñ½Ğµ÷Öð×
© UCLES 2024 ĬĖěá¾ĩÐÏßĊïĚ¼ýýÌåĂ
ĥõÕÕõĕåõåĥåÕĥÕąåµÕ
9618/23/M/J/24 [Turn over
* 0019655333810 *
Functions FormatA() and FormatB() apply fixed format case changes to the parameter string.
Suggest a more appropriate construct that could be used and explain your choice.
Construct ..................................................................................................................................
Explanation ...............................................................................................................................
...................................................................................................................................................
[2]
(b) The algorithm calls one of the functions FormatA() and FormatB() each time within the
loop.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [4]
ĬÑĊ¾Ġ³íÇ÷Íñ½Ğ¸õØî×
© UCLES 2024 ĬĖęâ¿ĝܹØ÷ĉõĄ÷ôÝĂ
ĥåÅÕµõĥĕĕåõĕĥĕĥĥĕÕ
9618/23/M/J/24
DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN
,
© UCLES 2024
* 0019655333811 *
ĥåµĕõĕąõąÕåĕĥõąåąÕ
ĬĖĚáÇīØÉáāø´ØÿĩôÍĂ
ĬÓĊ¾Ġ³íÇ÷Íñ½Ğ¸÷Øî×
,
11
9618/23/M/J/24
BLANK PAGE
[Turn over
* 0019655333812 *
6 A program displays a progress bar to inform the user of the progress of tasks that take a significant
time to complete, such as those involving file transfer operations.
Task progress is divided into 11 steps. Each step represents the amount of progress as a
percentage. An image is associated with each step and each image is stored in a different file.
Different progress bar images may be selected. For a given image, files all have the same filename
root, with a different suffix.
The table illustrates the process for using the image with filename root BargraphA
ĬÑĊ¾Ġ³íÇ÷Íñ½Ğ¶õØð×
© UCLES 2024 ĬĖĚäÇġæÀÖÿï»öãËĤåĂ
ĥĕĥĕµĕąÕĥõÕĕåõååĕÕ
9618/23/M/J/24
* 0019655333913 *
DO NOT WRITE IN THIS MARGIN
13
, ,
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN
............................................................................................................................................. [6]
ĬÓĉ¿Ġ³íÇ÷Íñ½ĞµõØð×
© UCLES 2024 ĬĖĚâÌĞÕêåþă½ģËÔÍĂ
ĥåÅÕµµåµąõõĕĥµåĥåÕ
9618/23/M/J/24 [Turn over
* 0019655333914 *
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [1]
ĬÍĉ¿Ġ³íÇ÷Íñ½Ğ¶öÕò×
© UCLES 2024 ĬĖęäÉĤêÒ×ČĈãġº¿ĤÕĂ
ĥąÅĕõÕĥĕĥĥõÕåõąåõÕ
9618/23/M/J/24
DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN
,
© UCLES 2024
* 0019655333915 *
ĥąµÕµµąõõĕåÕåĕĥĥĥÕ
ĬĖĚãÁĦæââîùĦµÂěĤåĂ
ĬÏĉ¿Ġ³íÇ÷Íñ½Ğ¶øÕò×
,
15
9618/23/M/J/24
BLANK PAGE
[Turn over
* 0019655333916 *
7 Seven program modules form part of a program. A description of the relationship between the
modules is summarised below. Any return values are stated in the description.
..................................................................................................................................... [1]
(ii) Modules Mod-F and Mod-G are both called with Par3 as a parameter.
In the case of Mod-F, the parameter is passed by value.
In the case of Mod-G, the parameter is passed by reference.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
..................................................................................................................................... [2]
DO NOT WRITE IN THIS MARGIN
ĬÍĉ¿Ġ³íÇ÷Íñ½Ğ¸öÕô×
© UCLES 2024 ĬĖĚâÁĠØçÕôòĝėйôÍĂ
ĥµĥÕõµąÕĕµÕÕĥĕÅĥõÕ
9618/23/M/J/24
* 0019655333917 *
DO NOT WRITE IN THIS MARGIN
17
, ,
(b) Draw a structure chart to show the relationship between the seven modules and the
parameters passed between them.
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
[6]
ĬÏĉ¿Ġ³íÇ÷Íñ½Ğ¸øÕô×
© UCLES 2024 ĬĖęáÉĪÜ×äĆÿìÃĖĝôÝĂ
ĥµĕĕµÕĥµąÅąÕĥõååĥÕ
9618/23/M/J/24 [Turn over
* 0019655333918 *
The program analyses a student project and extracts information about each module that is
defined (each procedure or function). This information is stored in a global 2D array ModInfo of
type string.
A module header is the first line of a module definition and starts with either of the keywords
PROCEDURE or FUNCTION.
An example of part of the array is given below. Row 10 of the array shows that a procedure header
occurs on line 27 and row 11 shows that a function header occurs on line 35. "P" represents a
x = 1 x = 2 x = 3
The string stored in column 3 is called the module description. This is the module header without
the keyword.
Module Description
Header() • called with a parameter of type string representing a line of
pseudocode
• if the line is a valid procedure header, returns a string:
"P<Module description>"
ĬÍĉ¿Ġ³íÇ÷Íñ½Ğµö×ò×
© UCLES 2024 ĬĖěâÌĞбÛûùÇûĠÍÌåĂ
ĥĥąĕõµåÕµąÕĕĥµÅĥÅÕ
9618/23/M/J/24
* 0019655333919 *
DO NOT WRITE IN THIS MARGIN
19
, ,
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [7]
DO NOT WRITE IN THIS MARGIN
ĬÏĉ¿Ġ³íÇ÷Íñ½Ğµø×ò×
© UCLES 2024 ĬĖĜáÄĬÔÁÞýĈĂßĘĉÌÕĂ
ĥĥõÕµÕŵåõąĕĥÕååÕÕ
9618/23/M/J/24 [Turn over
* 0019655333920 *
Module Description
FindModules() • called with a parameter of type string representing a student
project file name
• uses module Header() to check each line of the project
• assigns values to the ModInfo array for each module
declaration in the student project
Assume that the array contains enough rows for the number of modules in each project.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
ĬÍĉ¿Ġ³íÇ÷Íñ½Ğ·ö×ô×
© UCLES 2024 ĬĖĜäÄĢâÈÙăÿĉý¼ëÜÝĂ
ĥÕåÕõÕÅĕÅÕõĕåÕąåÅÕ
9618/23/M/J/24
* 0019655333921 *
DO NOT WRITE IN THIS MARGIN
21
, ,
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
DO NOT WRITE IN THIS MARGIN
...................................................................................................................................................
...................................................................................................................................................
............................................................................................................................................. [8]
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN
ĬÏĉ¿Ġ³íÇ÷Íñ½Ğ·ø×ô×
© UCLES 2024 ĬĖěãÌĨÞ¸àõòÀÙÄïÜÍĂ
ĥÕÕĕµµåõÕååĕåµĥĥÕÕ
9618/23/M/J/24
,
© UCLES 2024
* 0019655333922 *
ĥąõĕµĕåÕĕÅąĕĥµÅåąÕ
ĬĖĜãÇĞÆ®èòăµ¹¼ĎôÝĂ
ĬÑĉ¿Ġ³íÇ÷Íñ½Ğ¶øÖò×
,
22
9618/23/M/J/24
BLANK PAGE
DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN
DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN DO NOT WRITE IN THIS MARGIN
,
© UCLES 2024
* 0019655333923 *
ĥąąÕõõŵąµÕĕĥÕåĥĕÕ
ĬĖěä¿ĬʾÑĈîôĝÄÊôÍĂ
ĬÓĉ¿Ġ³íÇ÷Íñ½Ğ¶öÖò×
,
23
9618/23/M/J/24
BLANK PAGE
* 0019655333924 *
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.
ĬÑĉ¿Ġ³íÇ÷Íñ½Ğ¸øÖô×
© UCLES 2024 ĬĖěá¿Ģ¼ËæĊõû¿ĠĬĤåĂ
ĥµÕÕµõÅĕĥĕåĕåÕąĥąÕ
9618/23/M/J/24