Algorithm design and problem-solving – O Level Computer Science (2210)

61 questions · page 1 of 5 · Clear filters

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
1
2210/22/O/N/25 · Question 3Oct/Nov 2025Paper 226 marks
Loading question…
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]
ĬÍĊ®Ġ´íÈõÏĪÅĊàü¸Ā×

2
2210/22/O/N/25 · Question 4Oct/Nov 2025Paper 227 marks
Loading question…
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]
ĬÏĊ®Ġ´íÈõÏĪÅĊàú¸Ā×

3
2210/22/O/N/25 · Question 5Oct/Nov 2025Paper 2234 marks
Loading question…
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]
ĬÑĊ®Ġ´íÈõÏĪÅĊßúµĀ×

Advertisement
4
2210/23/O/N/25 · Question 4Oct/Nov 2025Paper 2314 marks
Loading question…
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]
ĬÍĊ®Ġ´íÈõÏĪÅĊÝû·Ā×

5
2210/23/O/N/25 · Question 5Oct/Nov 2025Paper 236 marks
Loading question…
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]
ĬÏĊ®Ġ´íÈõÏĪÅĊÝù·Ā×

6
2210/23/O/N/25 · Question 6Oct/Nov 2025Paper 239 marks
Loading question…
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]
ĬÓĊ®Ġ´íÈõÏĪÅĊàû¶þ×

7
2210/23/O/N/25 · Question 7Oct/Nov 2025Paper 238 marks
Loading question…
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]
ĬÓĊ®Ġ´íÈõÏĪÅĊÞû¶Ā×

8
2210/22/O/N/24 · Question 1Oct/Nov 2024Paper 221 marks
Loading question…
Question text

1
Tick (✓) one box to complete this sentence.
A solution to a problem may be represented using pseudocode, flowcharts or
A
procedures.
B
processes.
C
structure diagrams.
D
sub-systems.
[1]

Advertisement
9
2210/22/O/N/24 · Question 3Oct/Nov 2024Paper 2210 marks
Loading question…
Question text

3
Four flowchart symbols and five purposes are shown.
(a) Draw one line to link each flowchart symbol to its correct purpose.
Not all purposes will be used.
Flowchart symbol
Purpose
subroutine
process
flow
decision
terminator
[4]
ĬÍĊ®Ġ´íÈõÏĪÅĊÞû·þ×
,
,
(b) An algorithm needs to total 50 numbers between 1 and 100 inclusive.
Draw a flowchart that:
•
uses a count-controlled loop from 1 to 50
•
uses an appropriate prompt to ask for a number between 1 and 100
•
totals the numbers as they are entered
•
outputs the total after the loop has completed with an appropriate message.
[6]
ĬÏĊ®Ġ´íÈõÏĪÅĊÞù·þ×

10
2210/22/O/N/24 · Question 4Oct/Nov 2024Paper 228 marks
Loading question…
Question text

4
This pseudocode algorithm is intended to sort a pre-populated one-dimensional (1D) array named
ItemList into alphabetical order using a bubble sort.
01
DECLARE ItemList : ARRAY[1:100] OF STRING
02
DECLARE Counter : STRING
03
DECLARE Limit : INTEGER
04
DECLARE Pass : INTEGER
05
DECLARE Swapped : BOOLEAN
06
DECLARE Temp : STRING
100
07
Limit
1
08
Pass
TRUE
09
Temp
10
WHILE Swapped = TRUE OR Pass <= Limit - 1 DO
FALSE
11
Swapped
1 TO Limit – Pass
12
FOR Counter
13
IF ItemList[Counter] > ItemList[Counter + 1]
14
THEN
ItemList[Counter]
15
Temp
ItemList[Counter + 1]
16
ItemList[Counter]
Temp
17
ItemList[Counter]
TRUE
18
Swapped
19
ENDCASE
Pass + 1
20
Pass
21
NEXT Counter
22
ENDWHILE
(a) Identify the line numbers of five 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 …
…
Error 4 line number …
Correction …
…
ĬÍĊ®Ġ´íÈõÏĪÅĊàû·Ā×
,
,
Error 5 line number …
Correction …
…
[5]
(b) A bubble sort algorithm can be written to include features that make it more efficient.
Explain why the corrected bubble sort algorithm is efficient.
…
…
…
…
…
… [3]

11
2210/22/O/N/24 · Question 5Oct/Nov 2024Paper 224 marks
Loading question…
Question text

5
Analysis is one stage in the program development life cycle.
(a) State one other stage in the program development life cycle.
… [1]
(b) Describe the analysis stage of the program development life cycle.
…
…
…
…
…
… [3]

12
2210/22/O/N/24 · Question 6Oct/Nov 2024Paper 222 marks
Loading question…
Question text

6
Outline one type of verification check that could be used when inputting data.
…
…
…
… [2]
ĬÏĊ®Ġ´íÈõÏĪÅĊàù·Ā×

13
2210/22/O/N/24 · Question 8Oct/Nov 2024Paper 224 marks
Loading question…
Question text

8
Different types of test data are used during program development to make sure a program works
as intended. A program being developed takes as input whole numbers that are not greater than
80.
Identify two items of test data to test the whole number limit of 80.
Explain the reason for your choice of the data in each case.
Test data 1 …
Reason for choice …
…
Test data 2 …
Reason for choice …
…
[4]
ĬÓĊ®Ġ´íÈõÏĪÅĊÝû¶þ×

Advertisement
14
2210/23/O/N/24 · Question 1Oct/Nov 2024Paper 231 marks
Loading question…
Question text

1
Tick (✓) one box to show which of the following is used to validate data on input.
A
checksum
B
double entry check
C
type check
D
visual check
[1]

15
2210/23/O/N/24 · Question 2Oct/Nov 2024Paper 231 marks
Loading question…
Question text

2
Tick (✓) one box to show a method used to construct a solution to a problem.
A
abstraction
B
structure diagram
C
test data
D
variable
[1]

Advertisement