Algorithm design and problem-solving – O Level Computer Science (2210)
Quick quiz: 10 random questions from this topic. Answer them all, then open the Summary.
Question text
5
The flowchart checks the level of chlorine and the depth of water compared to the height of the
swimming pool. Error messages are output if a problem is found.
START
INPUT Height,
Depth, Chlorine
OK
True
OUTPUT
Yes
Is Depth >
"Water too
Height/2 ?
deep"
No
OUTPUT
Is Depth <
Yes
"Water too
Height/3 ?
shallow"
No
OK
False
OUTPUT "Too
Yes
Is Chlorine
much chlorine
>3 ?
add more water"
No
OUTPUT "Too
Yes
little chlorine
Is Chlorine
add more chlorine"
<1 ?
No
No
Is OK = True ?
Yes
OUTPUT "Pool OK
to use"
END
(a) Complete the trace tables for each set of input data.
Input data: 6, 2.5, 2
Height
Depth
Chlorine
OK
OUTPUT
Input data: 4, 3, 1.5
Height
Depth
Chlorine
OK
OUTPUT
Input data: 6, 3.5, 4
Height
Depth
Chlorine
OK
OUTPUT
[6]
(b) Identify a problem with the algorithm that the flowchart represents.
…
… [1]
Question text
Tick ( ü ) one box in each row to identify if the statement is about validation, verification or both.
2
Verification
Both
Validation
Statement
( ü )
( ü )
( ü )
Entering the data twice to check if both entries are
the same.
Automatically checking that only numeric data has
been entered.
Checking data entered into a computer system
before it is stored or processed.
Visually checking that no errors have been
introduced during data entry.
[3]
Question text
5
The flowchart represents an algorithm.
The algorithm will terminate if –1 is entered at the List input.
START
← 0
List1
← 0
List2
INPUT
List
IS
Yes
List = –1 ?
No
INPUT
Value
← List1 + Value
Yes
IS
List1
List = 1 ?
No
← List2 + Value
Yes
IS
List2
List = 2 ?
OUTPUT
"List 1 = ", List1
No
OUTPUT
OUTPUT
"Input Error"
"List 2 = ", List2
IS
Yes
List1 > List2 ?
No
OUTPUT
"List 1 is greatest"
OUTPUT
"List 2 is greatest"
END
Complete the trace table for the algorithm using this input data:
2, 77, 2, 16, 1, 35, 2, –7, 5, 18, 1, 11, 1, 12, 2, 20, –1, 18
List
Value
List1
List2
OUTPUT
[5]
Question text
6
This flowchart inputs a range of temperatures in degrees Fahrenheit.
As each temperature is input, it is compared with the previous highest temperature. If it is higher
than the current highest, it replaces the previous highest temperature and then it is converted to
degrees Celsius.
For ease of calculation, the final step of the Fahrenheit to Celsius conversion has been
approximated as division by 2.
When –1 is entered, the input process stops and the highest temperature (in both Fahrenheit and
Celsius) is output.
START
HighF
-100
HighC
-100
INPUT TempF
No
No
Is TempF
Is TempF
> HighF?
= -1?
Yes
Yes
HighF
TempF
HighC
(TempF-32)/2
OUTPUT 'The highest temperature is, ',
HighF, ' Fahrenheit, ',
HighC, ' Celsius.'
END
Complete the trace table for the input data:
68, 46, 50, 86, 65, 50, 40, 30, –1
HighF
HighC
TempF
OUTPUT
[5]
Question text
3
(a) Explain the difference between a validation check and a verification check.
…
…
… [2]
(b) Describe, using an example, how data could be verified on data entry.
…
…
… [2]
(c) Explain what is meant by the term library routine.
…
…
… [2]
Question text
1
Tick (✓) one box to identify the first stage of the program development life cycle.
A
Analysis
B
Coding
C
Design
D
Testing
[1]
Question text
4
A programmer has written a routine to store the name, email address and password of a contributor
to a website’s discussion group.
(a) The programmer has chosen to verify the name, email address and password.
Explain why verification was chosen and describe how the programmer would verify this data.
…
…
…
…
…
…
…
…
… [4]
(b) The programmer has also decided to validate the email address and the password.
Describe validation checks that could be used.
Email address …
…
…
Password …
…
…
[2]
Question text
3
This flowchart inputs the marks gained in an examination. An input of –1 ends the routine.
START
Total
0
Count
0
Distinction
0
INPUT Mark
Yes
Is Mark = –1 ?
Total
Total + Mark
Count
Count + 1
No
OUTPUT "Number of
No
Is
Distinctions ", Distinction
Mark >=
OUTPUT "Average Mark "
80 ?
Total/Count
Yes
END
Distinction
Distinction + 1
Complete the trace table for the mark input data: 50, 70, 65, 30, 95, 50, 55, 85, 65, 35, –1, 45
OUTPUT
Total
Count
Distinction
Mark
[4]
Question text
3
A satellite navigation system works using destination details entered by the user, either a new
destination or chosen from previously saved destinations. The satellite navigation system will then
output directions to the destination in the form of either a visual map or a list of directions.
A satellite navigation system is an example of a computer system that is made up of sub-systems.
This structure diagram shows some of its sub-systems.
Complete the diagram by filling in the empty boxes.
Satellite navigation system
Input destination
Map
List
[2]
Question text
5
This pseudocode represents an algorithm.
REPEAT
0
Flag
0 to 3
FOR Count
IF Num[Count] < Num[Count + 1]
THEN
Num[Count]
Store
Num[Count + 1]
Num[Count]
Store
Num[Count + 1]
1
Flag
ENDIF
NEXT Count
UNTIL Flag = 0
(a) The contents of the array at the start of the algorithm are:
Num[0]
Num[1]
Num[2]
Num[3]
Num[4]
45
56
30
12
15
Complete the trace table for the algorithm using the data given in the array.
Flag
Count
Num[0]
Num[1]
Num[2]
Num[3]
Num[4]
Store
45
56
30
12
15
[5]
(b) Describe the purpose of the algorithm.
…
…
…
… [2]