Algorithm design and problem-solving – O Level Computer Science (2210)
137 questions · page 2 of 10 · Clear filters
Question text
1
Tick ( ü ) one box to identify the type of test to only check for the largest or smallest acceptable
value.
A
normal test data
B
abnormal test data
C
extreme test data
D
boundary test data
[1]
Question text
2
Four requirements for validating inputs and five types of validation check are given.
(a) Draw one line from each requirement to the most appropriate validation check.
Not all validation checks will be used.
Requirement
Validation check
length check
Date of birth must be between
01/01/1900 and 01/01/2010.
format check
Name has been entered.
range check
Password has exactly 12 characters.
check digit
Student ID must contain 2 letters followed
by a 4-digit number.
presence check
[4]
(b) Identify and describe one verification check that could be applied when a new password is
input into a system.
Verification check …
Description …
…
…
…
[3]
ĬÍĊ®Ġ´íÈõÏĪÅĊÞû·þ×
Question text
4
A telephone number with 13 characters is input. The first character is a ‘+’, followed by a 2-digit
country code, for example:
+20xxxxxxxxxx where 20 is the country code and x is a digit between 0 and 9 inclusive.
The algorithm includes checks for the country codes: 44 for the UK and 20 for Egypt.
(a) Write an algorithm using pseudocode to:
•
input the telephone number
•
extract the 2-digit country code
•
output the matching country
•
output ‘Unknown’ if there is no matching country.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [5]
ĬÍĊ®Ġ´íÈõÏĪÅĊàû·Ā×
,
,
(b) Explain how you could change the algorithm to repeatedly prompt for the telephone number
until the number entered is 13 characters in length.
Any code used must be fully explained.
…
…
…
…
Question text
10 The flowchart represents an algorithm to calculate grades.
START
INPUT
Score
IS Score
Yes
Grade
"C"
>= 40 ?
No
IS Score
Yes
Grade
"B"
>= 60 ?
No
IS Score
Yes
Grade
"A"
>= 80 ?
No
Grade
"D"
OUTPUT "You
achieved a ", Grade
STOP
ĬÑĊ®Ġ´íÈõÏĪÅĊÞù¸þ×
,
,
(a) Complete the trace table for the algorithm, using the input data:
21, 46, 63, 91, 12
Score
Grade
OUTPUT
[3]
(b) Explain how the flowchart can be changed to produce the correct output.
…
…
…
…
…
…
…
… [4]
ĬÓĊ®Ġ´íÈõÏĪÅĊÞû¸þ×
Question text
1
Tick (✓) one box to complete the description of abstraction.
Abstraction is part of the analysis stage of the development life cycle. Abstraction means
A
testing the solution to the problem.
B
writing a program using program code.
C
defining the sub-systems that make up the problem.
D
removing details from the problem that are not relevant.
[1]
Question text
3
A range check is used to validate that the input temperature is an integer between –100 and 0,
inclusive.
Suggest suitable normal, abnormal, extreme and boundary test data to test if this validation check
is working correctly.
Normal test data …
Abnormal test data …
Extreme test data …
Boundary test data …
[4]
Question text
4
(a) State one reason for using a verification check when inputting data.
…
… [1]
(b) Write the pseudocode for an algorithm to perform a double entry verification check, using the
following criteria:
•
Input 10 numbers and store them in the array Numbers[]
•
Input the same 10 numbers again; as each number is input, compare it with its
corresponding number in the array Numbers[]
◦
if the numbers match, move on to the next number
◦
if the numbers do not match, display both numbers and ask for the number to be
re-entered
◦
store the re-entered number in the corresponding array location and move on to the
next number.
•
When all the numbers have been checked, display a message to say the check has
been completed.
You do not need to declare any arrays or variables for this algorithm.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]
Question text
7
The flowchart shows an algorithm that is used to input 50 numbers. Each number is stored in the
variable Value when it is input. Any number input that is less than or equal to –20 or greater than
or equal to 50 is rejected and re-input. The accepted numbers are added together as they are
entered and the total and average of these numbers are output at the end of the algorithm.
(a) Complete the flowchart.
START
0
Count
0
Total
Yes
No
No
Yes
STOP
[6]
(b) Explain how you would alter the flowchart in 7(a) so that it will individually store each accepted
value as it is entered and then output all the numbers, one after the other, outside of the loop
that inputs values.
You may include program statements or flowchart symbols in your answer, but they must be
fully explained.
…
…
…
…
…
…
…
…
…
… [4]
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]
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]
ĬÏĊ®Ġ´íÈõÏĪÅĊÞù·þ×
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]
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]
Question text
6
Outline one type of verification check that could be used when inputting data.
…
…
…
… [2]
ĬÏĊ®Ġ´íÈõÏĪÅĊàù·Ā×
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]
ĬÓĊ®Ġ´íÈõÏĪÅĊÝû¶þ×
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]