Algorithm design and problem-solving – O Level Computer Science (2210)
137 questions · page 1 of 10 · Clear filters
Question text
1
Tick (3) one box to identify the type of validation check to test whether a number entered into a
computer system is between two set values.
A
length check
B
presence check
C
type check
D
range check
[1]
Question text
4
The following pseudocode algorithm uses a bubble sort to sort the array Names[50]
Complete the algorithm.
…
Last
REPEAT
…
Swap
1 TO Last ‑ 1
FOR …
IF Names[Index] > Names[Index + 1]
THEN
Names[Index]
Temp
Names[Index + 1]
Names[Index]
Temp
Names[Index + 1]
TRUE
Swap
ENDIF
NEXT Index
Last ‑ 1
Last
UNTIL … Swap OR Last = 1
[4]
© Cambridge University Press & Assessment 2026
Question text
5
A computer system automatically creates usernames for new users. A new user enters their first
name and their last name.
The system:
•
takes the first letter of the first name
•
takes the first two letters of the last name
•
converts all the letters to upper case
•
generates a random whole number between 1 and 1000 inclusive.
For the following example:
The first name is Muhammed
The last name is Hann
The generated number is 492
The username will be MHA492
(a) Write the pseudocode to generate a whole random number between 1 and 1000 inclusive
and store it in the variable GeneratedNumber
…
…
… [2]
(b) The last name is input into the variable LastName
Write the pseudocode to:
•
take the first two letters from LastName
•
convert the letters to upper case
•
store the result in the variable Temp
…
…
… [3]
(c) The new username is stored in the variable NewUsername
Write the pseudocode to store NewUsername to the file Username.txt
…
…
…
… [3]
© Cambridge University Press & Assessment 2026
,
,
(d) Identify and describe verification checks that could be applied to the inputs of the first name
and the last name of the user.
…
…
…
…
…
… [4]
Question text
10 (a) Draw a flowchart to input six whole numbers and output the highest. You do not need to
validate the inputs.
START
[6]
© Cambridge University Press & Assessment 2026
,
,
(b) Describe how the flowchart could be changed to only accept positive whole numbers.
…
…
…
…
…
… [3]
Question text
3
(a) Identify the type of validation check used in each description.
(i)
A check to make sure that data has been input and not left blank.
… [1]
(ii)
A value placed at the end of a sequence of numbers in the code. The value is calculated
from all the other values before it.
… [1]
(b) Explain the purpose of a format check and give an example of where it could be used.
purpose …
…
…
…
…
example …
…
[3]
© Cambridge University Press & Assessment 2026
,
,
(c) Write the pseudocode for an algorithm to perform a validation check on each number as it is
input, using the following criteria:
•
Input one number at a time.
•
If the number is a whole number, store it in the current element of array Accepted[]
•
If the number is not a whole number, ask for it to be input again until it is a
whole number.
•
When 15 whole numbers have been stored, output a message that states the check has
been completed.
Use appropriate input prompts and output messages to make the requirements clear to
the user.
You do not need to declare any arrays or variables for this algorithm.
…
…
…
…
…
…
…
…
…
…
…
…
Question text
4
The program development life cycle is split into several stages.
Outline what happens during the coding and testing stages of the program development
life cycle.
coding …
…
…
…
…
…
testing …
…
…
…
…
…
[6]
© Cambridge University Press & Assessment 2026
,
,
© Cambridge University Press & Assessment 2026
Question text
6
This flowchart represents an algorithm.
START
INPUT Word
WordLength
LENGTH (Word)
0
Count
1
NumLetter
IS SUBSTRING(Word, NumLetter, 1)
Yes
= SUBSTRING(Word, NumLetter + 1
, 1) ?
Count
Count + 1
No
NumLetter
NumLetter + 1
IS
OUTPUT Count
Yes
No
NumLetter =
WordLength
?
INPUT Choice
Yes
Is Choice =
'Y' ?
No
STOP
© Cambridge University Press & Assessment 2026
,
,
(a) Complete the trace table for the algorithm, using the input data:
post, Y, committee, N, bookkeeper
Note: the first character of each word is in position 1.
Word
WordLength
Count
NumLetter
Choice
OUTPUT
[6]
(b) State the purpose of the algorithm shown by the flowchart.
…
… [1]
© Cambridge University Press & Assessment 2026
Question text
7
(a) State one reason to store data in a file.
…
… [1]
(b) A list of names of the members of a club are stored in a file called Names.txt
Write the pseudocode statements to load a line of text from Names.txt and assign the line
of text to an appropriately named variable.
…
…
…
…
…
…
…
… [4]
© Cambridge University Press & Assessment 2026
Question text
3
A program is written that will only accept values between –99.99 and +99.99, inclusive.
The program is to be tested.
The table, when completed, shows appropriate test data that matches the type of test data and
purpose of the test data.
Complete the table by inserting the missing information.
Test data
Type of test data
Purpose of test data
…
0
…
…
boundary
…
to make sure that the program rejects data that is
outside acceptable limits
[6]
ĬÍĊ®Ġ´íÈõÏĪÅĊàü¸Ā×
Question text
4
(a) A length check is a type of validation check.
State the purpose of a length check.
…
… [1]
(b) An email address can be validated by checking that it contains an @ symbol.
Write the pseudocode for an algorithm that will allow an email address to be input and check
whether or not it contains an @ symbol.
Output a suitable message with the result.
Use the string function SUBSTRING(EmailAddress, Start, 1) in your solution to return a
string of length 1 character, starting at position Start, where EmailAddress is the identifier
representing your input.
You do not need to declare any variables for this algorithm, but variables must be initialised
as necessary. Assume there will not be more than one @ symbol in the email address input.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]
ĬÏĊ®Ġ´íÈõÏĪÅĊàú¸Ā×
Question text
5
This flowchart represents an algorithm.
START
INPUT Code
OUTPUT "Length
must be 4"
IS
No
LENGTH(Code)
= 4 ?
Yes
Store
FALSE
No
OUTPUT "Code
Count
1
used before"
Yes
IS Store =
FALSE ?
IS
Yes
CodeStore[Count]
= Code ?
No
IS
No
Yes
CodeStore[Count]
= "" ?
Store
TRUE
CodeStore[Count]
Code
Count
Count + 1
No
Yes
IS Count > 6
?
OUTPUT
"CodeStore
full"
STOP
ĬÑĊ®Ġ´íÈõÏĪÅĊÝúµþ×
,
,
(a) The first data row of the trace table shows the values currently stored in CodeStore[]
Complete the trace table for the algorithm, using the input data:
7686, Face, Speed, 432U, Yp79
CodeStore[]
Code
Store
Count
[1]
[2]
[3]
[4]
[5]
[6]
OUTPUT
aBcd
1532
Face
63q8
[6]
ĬÓĊ®Ġ´íÈõÏĪÅĊÝüµþ×
,
,
(b) Describe the processes in the algorithm on page 6.
…
…
…
…
…
… [3]
(c) The algorithm on page 6 requires the array CodeStore[] to be declared as a
one‑dimensional (1D) string array with six elements that are initially set to the null string "".
Write the pseudocode required to declare and initialise the array CodeStore[]
You do need to declare any variables used.
…
…
…
…
…
…
…
… [4]
ĬÑĊ®Ġ´íÈõÏĪÅĊßúµĀ×
Question text
4
(a) Tickets for a theme park are booked online. An adult ticket costs $12.99 and a child ticket
costs $7.99. A booking fee of $1.99 is added to the total cost of each booking.
Write an algorithm in pseudocode to:
•
input the number of adult tickets for a booking
•
input the number of child tickets for a booking
•
calculate and output the total cost of the booking using an appropriate message.
…
…
…
…
…
…
…
… [4]
(b) Each booking must have at least one adult ticket.
Explain how the algorithm could be changed to repeatedly ask for the number of adult tickets
if the number input is less than 1.
Any code used must be fully explained.
…
…
…
…
…
…
…
… [4]
ĬÏĊ®Ġ´íÈõÏĪÅĊßù·þ×
,
,
(c) The theme park has rules for a person to be able to go on a ride.
A person can go on a ride (X = 1) only if they:
•
are 1.4 metres tall or over
•
are 12 years old or over
•
do not have a medical condition.
Input
Description
Binary value
under 1.4 metres
0
A
1.4 metres or over
1
under 12 years old
0
B
12 years old or over
1
does not have a medical condition
0
C
has a medical condition
1
(i)
Write the logic expression for this problem.
X = … [2]
(ii)
Complete the truth table for this problem.
Working space
A
B
C
X
0
0
0
0
0
1
0
1
0
0
1
1
1
0
0
1
0
1
1
1
0
1
1
1
[4]
ĬÍĊ®Ġ´íÈõÏĪÅĊÝû·Ā×
Question text
5
A program has been written in pseudocode to input five numbers between 1 and 900 inclusive and
store the highest number and the lowest number entered.
900
01
Lowest
1
02
Highest
1 TO 5
03
FOR Count
04
INPUT Number
05
IF Number < Lowest
06
THEN
Number
07
Lowest
08
ELSE
09
IF Number > Highest
10
THEN
Number
11
Highest
12
ENDIF
13
ENDIF
14
NEXT Count
(a) Complete the trace table for the algorithm using the following numbers:
563, 21, 376, 99, 400
Count
Number
Lowest
Highest
[4]
(b) The algorithm does not work correctly.
State the reason why the algorithm does not work as expected and explain how the algorithm
could be corrected.
Any code used must be fully explained.
Reason …
…
Correction …
…
[2]
ĬÏĊ®Ġ´íÈõÏĪÅĊÝù·Ā×
Question text
6
The flowchart represents an algorithm.
START
Position
–1
Count
1
INPUT Name
IS Name =
Yes
Position
Count
ClassList[Count]
?
No
Count
Count + 1
No
IS Count
> 5 ?
Yes
OUTPUT
Position
STOP
ĬÑĊ®Ġ´íÈõÏĪÅĊàù¶þ×
,
,
(a) The algorithm uses the one-dimensional (1D) array ClassList that contains the following
data:
ClassList
1
2
3
4
5
Henil
Sven
Ella
Asia
Ridwan
Complete the table by writing the output from the flowchart when each of the given names are
input.
Name
OUTPUT
Ridwan
Yan
Ella
[2]
(b) Identify the standard method of solution used by the flowchart.
… [1]
(c) Write the algorithm in pseudocode.
…
…
…
…
…
…
…
…
…
…
…
…
… [6]
ĬÓĊ®Ġ´íÈõÏĪÅĊàû¶þ×
Question text
7
An algorithm has been written in pseudocode to:
•
input a whole number between 1 and 255 inclusive
•
convert the input to an 8-bit binary number
•
store each bit of the binary number in an array.
For example, if the denary number 127 was input, the binary number 01111111 would be stored in
the array.
01
DECLARE BinaryArray : ARRAY[1:8] OF INTEGER
02
DECLARE DenaryNumber : CHAR
03
OUTPUT "Please enter a whole number between 1 and 255 inclusive "
04
INPUT DenaryNumber
7 TO 1 STEP -1
05
FOR Count
MOD(DenaryNumber,3)
06
BinaryArray[Count]
DIV(DenaryNumber,2)
07
DenaryNumber
08
NEXT Count
(a) Identify the line numbers of the three errors in the pseudocode and suggest a correction for
each error.
Error 1 line number …
Correction …
…
Error 2 line number …
Correction …
…
Error 3 line number …
Correction …
…
[3]
ĬÑĊ®Ġ´íÈõÏĪÅĊÞù¶Ā×
,
,
(b) Identify one programming technique used in the algorithm.
… [1]
(c) (i)
The algorithm can accept a number between 1 and 255 inclusive as input.
Two validation checks that could be applied to DenaryNumber are a presence check
and a type check.
Identify one other validation check that could be applied to DenaryNumber
… [1]
(ii)
Write the pseudocode to implement the validation check you identified in (c)(i).
You do not need to rewrite the whole algorithm.
…
…
…
…
…
… [3]
ĬÓĊ®Ġ´íÈõÏĪÅĊÞû¶Ā×