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

137 questions · page 5 of 10 · Clear filters

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
61
2210/22/M/J/23 · Question 9May/June 2023Paper 2237 marks
Loading question…
Question text

9
This flowchart represents an algorithm.
START
F
0
C
1
IS X[C] <
No
T
X[C]
X[C + 1]?
Yes
X[C]
X[C + 1]
X[C + 1]
T
F
1
C
C + 1
No
IS C = 5?
Yes
No
IS F = 0?
Yes
STOP
(a) The array X[1:5] used in the flowchart contains this data:
X[1]
X[2]
X[3]
X[4]
X[5]
10
1
5
7
11
Complete the trace table by using the data given in the array.
F
C
X[1]
X[2]
X[3]
X[4]
X[5]
T
10
1
5
7
11
[5]
(b) Describe what the algorithm represented by the flowchart is doing.
…
…
…
… [2]

62
2210/22/O/N/22 · Question 3Oct/Nov 2022Paper 223 marks
Loading question…
Question text

3
Describe the use of verification on input of data when entering a list of items in stock into a
database. Explain why verification is necessary.
…
…
…
…
…
… [3]

63
2210/22/O/N/22 · Question 4Oct/Nov 2022Paper 222 marks
Loading question…
Question text

4
Describe one type of test data that must be used to test if a program accepts valid input data.
…
…
…
… [2]

Advertisement
64
2210/22/O/N/22 · Question 5Oct/Nov 2022Paper 228 marks
Loading question…
Question text

5
This pseudocode should allow 500 marks to be entered into the algorithm. If the mark is 80 or
greater it is stored in an array for higher marks. If the mark is less than 80, but greater than or
equal to 50 it is stored in an array for middle marks. The remaining marks are stored in an array
for lower marks. The results from the algorithm are displayed at the end.
0
01
HighList
0
02
MidList
0
03
LowList
0
04
MarksEntry
05
REPEAT
06
INPUT Mark
07
IF Mark >= 80
08
THEN
MarksEntry
09
Higher[HighList]
HighList + 1
10
HighList
11
ELSE
12
IF Mark >= 50
13
THEN
Mark
14
Middle[MidList]
MidList
15
MidList
16
ELSE
Mark
17
Lower[HighList]
LowList + 1
18
LowList
19
ENDIF
20
ENDIF
MarksEntry + 1
21
MarksEntry
22
NEXT MarksEntry = 500
23
OUTPUT "You entered ", HighList, " higher marks"
24
OUTPUT "You entered ", MidList, " middle marks"
25
OUTPUT "You entered ", LowList, " lower marks"
(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) The corrected algorithm needs to be changed so that any number of marks may be entered
and the algorithm runs until the user tells it to stop.
Write the new pseudocode statements that would be needed to achieve this and state where
in the algorithm they would be placed.
…
…
…
…
…
…
…

65
2210/23/O/N/22 · Question 3Oct/Nov 2022Paper 239 marks
Loading question…
Question text

3
A check digit is to be used to validate an identification number on input. The identification number
contains five digits and the check digit.
The check digit is calculated by adding up the first five digits, dividing by 10 and taking the
remainder.
For example, 5 + 1 + 2 + 4 + 3 divided by 10 gives a remainder of 5 so the six-digit
identification number would be 512435
(a) (i)
Calculate the check digit for 69321
…
… [1]
Working space …
…
…
(ii)
State which of these identification numbers have incorrect check digits.
A 123455
B 691400
C 722855
D 231200
…
… [2]
Working space …
…
…
(b) (i)
Describe an input error that would not be found using this check digit.
…
…
…
… [2]
(ii)
Describe a more suitable algorithm to calculate the check digit for this identification
number.
…
…
…
… [2]
(c) Identify two other validation checks that could be used when inputting this identification
number.
1 …
…
2 …
…
[2]

66
2210/23/O/N/22 · Question 4Oct/Nov 2022Paper 237 marks
Loading question…
Question text

4
This algorithm makes sure that there are enough wheelbarrows in stock.
START
Stock
10
Total
0
INPUT Sale
Yes
Is Sale =
OUTPUT Total
"N"?
No
STOP
Stock
Stock – 1
Yes
OUTPUT
Is Stock
"Add new stock"
< 5?
No
Total
Total + 1
Stock
Stock + 10
(a) Complete the trace table for the algorithm using this input data:
“Y”, “Y”, “Y”, “Y”, “Y”, “Y”, “N”
Sale
Stock
Total
OUTPUT
[4]
(b) Explain how you could extend the algorithm to allow for the sale of more than one wheelbarrow
at a time.
…
…
…
…
…
…
… [3]

67
2210/21/M/J/22 · Question 1May/June 2022Paper 2120 marks
Loading question…
Question text

1
(a) Describe the data structures you could have used in Task 1. Your description should include
types of data structure, names used for data structures, their uses and examples of sample
data.
…
…
…
…
…
…
…
…
…
… [5]
(b) Explain how you could change your program in Task 1 to total all the money collected from
new members who have paid.
…
…
…
…
…
… [3]
(c) Describe how data input in Task 1 could be validated to find out if a new member wants to
work as a volunteer.
…
…
…
…
…
… [3]
(d) Write an algorithm to show how your program completes Task 3 assuming the option to
sponsor a wooden plank has been chosen, using pseudocode, programming statements or a
flowchart. Details completed in Task 1 are not required.
…

68
2210/21/M/J/22 · Question 3May/June 2022Paper 214 marks
Loading question…
Question text

3
Give one piece of normal test data and one piece of erroneous test data that could be used to
validate the input of an email address.
State the reason for your choice in each case.
Normal test data …
…
Reason …
…
…
…
Erroneous test data …
…
Reason …
…
…
…
[4]

Advertisement
69
2210/21/M/J/22 · Question 4May/June 2022Paper 2110 marks
Loading question…
Question text

4
The flowchart shows an algorithm that should allow 60 test results to be entered into the variable
Score. Each test result is checked to see if it is 50 or more. If it is, the test result is assigned to the
Pass array. Otherwise, it is assigned to the Fail array.
(a) Complete this flowchart:
START
PassCount
0
FailCount
0
Count
0
Yes
No
Count
Count + 1
No
Yes
END
[6]
(b) Write a pseudocode routine that will check that each test result entered into the algorithm is
between 0 and 100 inclusive.
…
…
…
…
…
…
…
…
…
… [4]

70
2210/22/M/J/22 · Question 2May/June 2022Paper 2211 marks
Loading question…
Question text

2
An algorithm allows a user to input their password and checks that there are at least eight
characters in the password. Then, the user is asked to re-input the password to check that both
inputs are the same. The user is allowed three attempts at inputting a password of the correct
length and a matching pair of passwords. The pre-defined function LEN(X) returns the number of
characters in the string, X
←
0
01
Attempt
02
REPEAT
←
TRUE
03
PassCheck
04
OUTPUT "Please enter your password "
05
INPUT Password
06
IF LEN(Password) < 8
07
THEN
←
TRUE
08
PassCheck
09
ELSE
10
OUTPUT "Please re-enter your password "
11
INPUT Password2
12
IF Password <> Password
13
THEN
←
FALSE
14
PassCheck
15
ENDIF
16
ENDIF
←
Attempt + 1
17
Attempt
18
UNTIL PassCheck OR Attempt <> 3
19
IF PassCheck
20
THEN
21
OUTPUT "Password success"
22
ELSE
23
OUTPUT "Password fail"
24
ENDIF
(a) Identify the three errors in the pseudocode and suggest a correction to remove each error.
Error 1 …
Correction …
Error 2 …
Correction …
Error 3 …
Correction …
[3]
(b) The algorithm includes two types of check on the data input.
Identify and describe each type of check.
Type of check 1 …
Description …
…
Type of check 2 …
Description …
…
[4]
(c) Give two sets of test data for this algorithm and a reason for choosing each set.
Each set of test data and its reason must be different.
Set 1 …
Reason …
…
Set 2 …
Reason …
…
[4]

71
2210/22/M/J/22 · Question 4May/June 2022Paper 229 marks
Loading question…
Question text

4
This algorithm checks the temperature of hot food being served to customers.
Error
START
Counter
0
Hot
0
Cold
0
Serve
0
INPUT Temp
Yes
Error
Is Temp
((Hot + Cold) / Counter) * 100
= –1?
No
Yes
OUTPUT
Is Temp
Hot
Hot + 1
"Too Hot"
> 86?
No
Counter
Counter + 1
OUTPUT
Error
Yes
Is Temp
Cold
Cold + 1
< 63?
No
OUTPUT
"Too Cold"
Serve
Serve + 1
END
(a) Complete the trace table for the algorithm using this input data:
75, 78, 84, 87, 91, 80, 75, 70, 65, 62, –1, 20
Counter
Hot
Cold
Serve
Temp
Error
OUTPUT
[7]
(b) State how the final output from the algorithm could be improved.
…
… [1]
(c) Identify the process in the algorithm that is not required.
…
… [1]

72
2210/22/O/N/21 · Question 2Oct/Nov 2021Paper 223 marks
Loading question…
Question text

2
Tick (3) one box in each row to identify if the statement is about validation, verification or neither.
Validation
Verification
Neither
Statement
(3)
(3)
(3)
a check where data is re-entered to make sure no
errors have been introduced during data entry
an automatic check to make sure the data entered
has the correct number of characters
a check to make sure the data entered is sensible
a check to make sure the data entered is correct
[3]

73
2210/22/O/N/21 · Question 3Oct/Nov 2021Paper 226 marks
Loading question…
Question text

3
A program checks that the data entered is between 1 and 100 inclusive.
Identify one piece of normal, extreme and erroneous test data for this program, and give a reason
for each.
Normal test data …
Reason …
…
…
Extreme test data …
Reason …
…
…
Erroneous test data …
Reason …
…
…
[6]

Advertisement
74
2210/22/O/N/21 · Question 4Oct/Nov 2021Paper 2210 marks
Loading question…
Question text

4
The pseudocode algorithm should work as a calculator and output the result.
1
1 Continue
2 WHILE Continue = 0
3
OUTPUT "Enter 1 for +, 2 for -, 3 for * or 4 for /"
4
INPUT Operator
5
OUTPUT "Enter the first value"
6
INPUT Value1
7
OUTPUT "Enter the second value"
8
OUTPUT Value2
9
IF Operator
Value1 + Value2
10
1: Answer
Value1 - Value2
11
2: Answer
Value1 * Value2
12
3: Answer
Value1 / Value2
13
4: Answer
14
ENDCASE
15
OUTPUT "The answer is ", Value1
16
OUTPUT "Do you wish to enter more values (Yes or No)?"
17
INPUT MoreValues
18
IF MoreValues = "No"
19
THEN
1
20
Continue
21
ENDIF
22 UNTIL Continue = 0
(a) Find the five errors in the pseudocode and suggest a correction for each error.
Error 1 …
Correction …
…
Error 2 …
Correction …
…
Error 3 …
Correction …
…
Error 4 …
Correction …
…
Error 5 …
Correction …
…
[5]
(b) The algorithm needs changing to allow only the numbers 1, 2, 3, or 4 to be entered for the
input variable Operator.
Write the pseudocode to perform this task and state where in the algorithm it would be
located.
Pseudocode …
…
…
…
…
…
…

75
2210/22/O/N/21 · Question 5Oct/Nov 2021Paper 225 marks
Loading question…
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]

Advertisement