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

137 questions · page 4 of 10 · Clear filters

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
46
2210/22/O/N/23 · Question 6Oct/Nov 2023Paper 227 marks
Loading question…
Question text

6
The flowchart represents an algorithm that performs a process on groups of values that are input.
The algorithm will fail if the first value of any group is 0.
An input of –1 will terminate the algorithm.
START
Total
0
OUTPUT
"Average is ",
Average
Count
0
OUTPUT
INPUT
"Total is ",
Value
Total
IS
Yes
Value =
Average
Total / Count
0 ?
No
IS
Yes
STOP
Value =
–1 ?
No
Total
Total + Value
Count
Count + 1
(a) Complete the trace table for the input data:
25, 35, 3, 0, 57, 20, 25, 18, 0, –1, 307, 40, 0
Value
Average
Total
Count
OUTPUT
[5]
(b) Describe the purpose of the algorithm.
…
…
…
… [2]

47
2210/23/O/N/23 · Question 1Oct/Nov 2023Paper 231 marks
Loading question…
Question text

1
Tick (3) one box to show which term is an example of a verification check.
A
Double entry check
B
Format check
C
Length check
D
Presence check
[1]

48
2210/23/O/N/23 · Question 3Oct/Nov 2023Paper 236 marks
Loading question…
Question text

3
(a) Four pseudocode descriptions and five pseudocode keywords are shown.
Draw one line to link each pseudocode description to the most appropriate pseudocode
keyword. Not all pseudocode keywords will be used.
Pseudocode description
Pseudocode keyword
OUTPUT
stores data in a file
WRITE
retrieves data from a file
READ
displays data on a screen
OPEN
enters data from a keyboard
INPUT
[4]
(b) Give two reasons for storing data in a file.
1 …
…
2 …
…
[2]

Advertisement
49
2210/23/O/N/23 · Question 4Oct/Nov 2023Paper 239 marks
Loading question…
Question text

4
A programmer is writing a data entry program for booking theatre seats.
The programmer needs the program to accept only whole numbers that are greater than or equal
to one and less than or equal to six.
(a) Give the names of two validation checks that are required for this program.
1 …
2 …
[2]
(b) Complete this pseudocode to perform your two validation checks, using your answers given
in (a):
OUTPUT "Please enter the number of seats you want to book "
INPUT Seats
…
…
…
…
…
…
…
…
…
[5]
(c) Give one item of test data to use when testing this program.
State the reason for your choice of test data.
Test data …
Reason for choice …
…
[2]

50
2210/23/O/N/23 · Question 5Oct/Nov 2023Paper 239 marks
Loading question…
Question text

5
An algorithm has been written in pseudocode to check if a new password is in a list of previously
used passwords OldList[]
If the password is not found, the new password will be stored at the end of the list to replace
"XXXX" already stored there.
01
OUTPUT "Enter your new password "
02
INPUT NewPassword
1
03
Posn
FALSE
04
Found
05
REPEAT
06
IF Password = OldList[Posn]
07
THEN
TRUE
08
Found
Posn + 1
09
ELSE Posn
10
ENDIF
11
UNTIL Found AND OldList[Posn] = "XXXX"
12
IF Found
13
THEN
14
OUTPUT "Password has been used before"
15
ELSE
16
INPUT "New password accepted"
NewPassword
17
OldList[Posn]
18
ENDIF
(a) Identify the three errors in the pseudocode and suggest corrections.
Error 1 …
Correction …
…
Error 2 …
Correction …
…
Error 3 …
Correction …
…
[3]
(b) Complete this flowchart for the corrected algorithm:
START
STOP
[6]

51
2210/23/O/N/23 · Question 8Oct/Nov 2023Paper 238 marks
Loading question…
Question text

8
This is an algorithm to find if a batch of parts has been manufactured successfully.
START
0
Accept
Reject
0
INPUT PartOK
No
IS PartOK
Reject
Reject + 1
= 'Y'?
Yes
Accept
Accept + 1
No
IS Accept
= 10 ?
Yes
Yes
IS Reject
Error
Reject/Accept * 100
> 1 ?
No
OUTPUT
"Too many rejected ",
OUTPUT
Error, "% error"
"Success"
STOP
(a) Complete the trace table using this data:
Y, Y, Y, N, Y, Y, Y, Y, N, Y, Y, Y, Y
Accept
Reject
PartOK
Error
OUTPUT
[5]
(b) Describe how the algorithm should be changed to accept ‘Y’ or ‘y’ for a successfully
manufactured part.
…
…
…
…
…
… [3]

52
2210/21/M/J/23 · Question 1May/June 2023Paper 217 marks
Loading question…
Question text

1
(a) Four descriptions of stages in the program development life cycle are shown.
Draw one line to link each description to its most appropriate program development life cycle
stage.
Not all program development life cycle stages will be used.
Program development life cycle description
Program development life cycle stage
analysis
develop an algorithm to solve the problem
by using structure diagrams, flowcharts or
pseudocode
coding
detect and fix the errors in the program
design
identify the problem and its requirements
evaluation
write and implement the instructions to
solve the problem
testing
[4]
(b) Identify three of the component parts after a problem has been decomposed.
1 …
…
2 …
…
3 …
…
[3]

53
2210/21/M/J/23 · Question 3May/June 2023Paper 218 marks
Loading question…
Question text

3
(a) Describe what is meant by data validation.
…
…
…
… [2]
(b) A validation check is used to make sure that any value that is input is an integer between 30
and 200 inclusive.
Give one example of each type of test data to check that the validation check is working as
intended. Each example of test data must be different.
Give a reason for each of your choices of test data.
Normal test data …
Reason …
…
Abnormal test data …
Reason …
…
Extreme test data …
Reason …
…
[6]

Advertisement
54
2210/21/M/J/23 · Question 5May/June 2023Paper 218 marks
Loading question…
Question text

5
An algorithm has been written in pseudocode to allow some numbers to be input. All the positive
numbers that are input are totalled and this total is output at the end.
An input of 0 stops the algorithm.
←
1
01
Exit
02
WHILE Exit <> 0 DO
03
INPUT Number
04
IF Number < 0
05
THEN
←
Total + Number
06
Total
07
ELSE
08
IF Number = 0
09
THEN
←
1
10
Exit
11
ENDIF
12
ENDIF
13
ENDIF
14
OUTPUT "The total value of your numbers is ", Number
(a) Identify the four errors in the pseudocode and suggest a correction for each error.
Error 1 …
Correction …
…
Error 2 …
Correction …
…
Error 3 …
Correction …
…
Error 4 …
Correction …
…
[4]
(b) Describe how you could change the corrected algorithm to record and output how many
positive numbers have been included in the final total.
You do not need to rewrite the algorithm.
…
…
…
…
…
…
…
… [4]

55
2210/21/M/J/23 · Question 7May/June 2023Paper 217 marks
Loading question…
Question text

7
The flowchart represents an algorithm.
START
Pointer
1
INPUT
Letter
IS
No
Word[Pointer, 1]
Pointer
Pointer
+ 1
= Letter ?
Yes
OUTPUT "Letter ", Letter,
" is represented by ",
Word[Pointer, 2]
OUTPUT "Another Letter?
(Y or N)"
INPUT Choice
IS
No
Yes
Choice =
STOP
'Y' ?
The table represents the two-dimensional (2D) array Word[] which stores the first half of the
phonetic alphabet used for radio transmission. For example, Word[10,1] is ‘J’.
Index
1
2
1
A
Alpha
2
B
Bravo
3
C
Charlie
4
D
Delta
5
E
Echo
6
F
Foxtrot
7
G
Golf
8
H
Hotel
9
I
India
10
J
Juliet
11
K
Kilo
12
L
Lima
13
M
Mike
(a) Complete the trace table for the algorithm by using the input data: F, Y, D, N
Pointer
Letter
Choice
OUTPUT
[4]
(b) Identify the type of algorithm used.
…
… [1]
(c) Describe one problem that could occur with this algorithm if an invalid character was input.
…
…
…
… [2]

56
2210/22/M/J/23 · Question 1May/June 2023Paper 221 marks
Loading question…
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]

57
2210/22/M/J/23 · Question 3May/June 2023Paper 223 marks
Loading question…
Question text

3
Identify three different ways that the design of a solution to a problem can be presented.
1 …
…
2 …
…
3 …
…
[3]

58
2210/22/M/J/23 · Question 4May/June 2023Paper 227 marks
Loading question…
Question text

4
A program needs to make sure the value input for a measurement meets the following rules:
•
the value is a positive number
•
a value is always input
•
the value is less than 1000.
(a) Describe the validation checks that the programmer would need to use.
…
…
…
…
…
… [3]
(b) The program needs editing to include a double entry check for the value input.
(i)
State why this check needs to be included.
…
… [1]
(ii)
The input value needs to be stored in the variable Measurement
Write pseudocode to perform the double entry check until a successful input is made.
…
…
…
…
…
…
…
… [3]

Advertisement
59
2210/22/M/J/23 · Question 5May/June 2023Paper 225 marks
Loading question…
Question text

5
Circle five file-handling operations.
calculate
close
count
create
input
open
output
print
read
sort
search
test
total
write
[5]

60
2210/22/M/J/23 · Question 7May/June 2023Paper 2215 marks
Loading question…
Question text

7
An algorithm has been written in pseudocode to calculate a check digit for a four-digit number.
The algorithm then outputs the five-digit number including the check digit.
The algorithm stops when –1 is input as the fourth digit.
FALSE
01 Flag
02 REPEAT
0
03
Total
1 TO 4
04
FOR Counter
05
OUTPUT "Enter a digit ", Counter
06
INPUT Number[Counter]
Total + Number * Counter
07
Total
08
IF Number[Counter] = 0
09
THEN
TRUE
10
Flag
11
ENDIF
12
NEXT Counter
13
IF NOT Flag
14
THEN
MOD(Total, 10)
15
Number[5]
0 TO 5
16
FOR Counter
17
OUTPUT Number[Counter]
18
NEXT
19
ENDIF
20 UNTIL Flag
(a) Give the line number(s) for the statements showing:
Totalling …
Count-controlled loop …
Post-condition loop …
[3]
(b) Identify the three errors in the pseudocode and suggest a correction for each error.
Error 1 …
Correction …
…
Error 2 …
Correction …
…
Error 3 …
Correction …
…
[3]
(c) The algorithm does not check that each input is a single digit.
Identify the place in the algorithm where this check should occur.
Write pseudocode for this check.
Your pseudocode must make sure that the input is a single digit and checks for –1
Place in algorithm …
Pseudocode …
…
…
…
…
…
[4]

Advertisement