2nd Last File
2nd Last File
* 7 3 4 4 0 3 2 3 6 4 *
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.