Algorithm design and problem-solving – IGCSE Computer Science (0478)

199 questions · page 8 of 14 · Clear filters

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
106
0478/21/O/N/21 · Question 3Oct/Nov 2021Paper 2110 marks
Loading question…
Question text

3
A program has been written to check the value of a measurement. The measurement must be a
positive number and given to three decimal places, for example, 3.982
(a) (i)
State suitable examples of normal and erroneous test data that could be used to test this
program. For each example give the reason for your choice of test data.
Normal test data example …
Reason …
…
Erroneous test data example …
Reason …
…
[4]
(ii)
Explain why two pieces of boundary test data are required for this program.
Give an example of each piece of boundary test data.
…
…
…
…
… [3]
(b) Explain why verification is needed and how verification could be performed by this program.
…
…
…
…
…
… [3]
Question 4 starts on Page 12

107
0478/21/O/N/21 · Question 4Oct/Nov 2021Paper 215 marks
Loading question…
Question text

4
The algorithm shown by this flowchart allows the input of examination marks for a class of students.
A mark of –1 ends the process. If a mark is 80 or over then a distinction grade is awarded. The
number of distinctions for the whole class is calculated. If this is over 50% of the class, the class is
awarded a highly commended certificate.
START
← 0
← 0
Counter
Distinction
INPUT
Mark
← Distinction/Counter
Yes
IS
Award
Mark = –1?
No
← Counter + 1
Yes
OUTPUT
IS
Counter
"Highly
Award > 0.5?
Commended"
No
← Distinction + 1
Distinction
END
IS
Yes
Mark >= 80?
No
Complete a trace table for the algorithm using this input data:
88, 74, 60, 90, 84, 87, 95, 72, 84, 66, –1
Counter
Distinction
Mark
Award
OUTPUT
[5]

108
0478/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]

Advertisement
109
0478/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]

110
0478/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]

111
0478/23/O/N/21 · Question 3Oct/Nov 2021Paper 2311 marks
Loading question…
Question text

3
A program has been written to check the length and content of a password. The password must be
eight or more characters long and contain at least one special character, for example, Secret!*!
(a) (i)
State suitable examples of normal and erroneous test data that could be used to test this
program. For each example give the reason for your choice of test data.
Normal test data example …
Reason …
…
Erroneous test data example …
Reason …
…
[4]
(ii)
Explain why two pieces of boundary test data are required for this program.
Give an example of each piece of boundary test data.
…
…
…
…
… [3]
(b) Describe two methods of verification that could be used to verify this data as it is input.
Method 1 …
…
…
Method 2 …
…
…
[4]

112
0478/23/O/N/21 · Question 4Oct/Nov 2021Paper 235 marks
Loading question…
Question text

4
The algorithm, shown by this flowchart, allows the input of examination marks for a class of
students. A mark of 999 ends the process. If a mark is 40 or over then a pass grade is awarded.
The number of pass grades is calculated for the whole class. If this is under 50% of the class, the
class is offered extra help.
START
Counter
0
Pass
0
INPUT
Mark
IS
Yes
Mark = 999 ?
Help
Pass / Counter
No
IS
Yes
OUTPUT
Counter
Counter + 1
Help < 0.5 ?
"Extra Help"
No
IS
Yes
Mark >= 40 ?
Pass
Pass + 1
END
No
Complete a trace table for the algorithm using this input data:
88, 24, 60, 30, 44, 17, 25, 22, 54, 6, 999, −1
Counter
Pass
Mark
Help
OUTPUT
[5]

113
0478/21/M/J/21 · Question 2May/June 2021Paper 213 marks
Loading question…
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]

Advertisement
114
0478/21/M/J/21 · Question 5May/June 2021Paper 216 marks
Loading question…
Question text

5
The flowchart represents an algorithm.
The algorithm will terminate if –1 is entered.
START
INPUT
Value
IS
Yes
Value =
–1 ?
OUTPUT
"Reject:
END
No
Abnormal"
IS
Value >= 50
No
AND Value
<= 100 ?
Yes
Diff1
100 – Value
Diff2
Value – 50
IS
No
OUTPUT
Diff1 < 1 OR
"Accept: Normal"
Diff2 < 1 ?
Yes
OUTPUT
"Accept:
Extreme"
(a) Complete the trace table for the input data:
50, 75, 99, 28, 82, 150, –1, 672, 80
Value
Diff1
Diff2
OUTPUT
[4]
(b) Describe the purpose of the algorithm.
…
…
…
… [2]

115
0478/22/M/J/21 · Question 1May/June 2021Paper 2220 marks
Loading question…
Question text

1
All variables, constants and other identifiers must have meaningful names.
(a) Identify and give the data type and use of one array that you could have used for Task 1.
Array …
Data type …
Use …
[3]
(b) Describe two validation checks that could be used when inputting the number of tickets to
buy for Task 2. For each validation check give one example of normal data and one example
of erroneous data.
Validation check 1 …
…
…
Normal data …
Erroneous data …
Validation check 2 …
…
…
Normal data …
Erroneous data …
[6]
(c) Write an algorithm for the part of Task 2 that inputs the tickets required, calculates the total
price for the ticket(s) purchased by a passenger including a group discount (if applicable) and
updates the data structures used for the totals.
Use either pseudocode, programming statements or a flowchart.
…
…
…
…
…
…
…
…
…
…

116
0478/22/M/J/21 · Question 2May/June 2021Paper 228 marks
Loading question…
Question text

2
(a) Write an algorithm in pseudocode to input 500 positive whole numbers. Each number input
must be less than 1000. Find and output the largest number input, the smallest number input
and the range (difference between the largest number and smallest number).
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]
(b) Describe how the algor

117
0478/22/M/J/21 · Question 3May/June 2021Paper 226 marks
Loading question…
Question text

3
(a) Draw the most appropriate flowchart symbol for each pseudocode statement.
Pseudocode statement
Flowchart symbol
IF Number = 20
PRINT Number
← Number + 1
Number
[3]
← X + Y is totalling.
(b) State the type of each pseudocode statement. For example, X
IF Number = 20 …
PRINT Number …
← Number + 1 …
Number
[3]

118
0478/23/M/J/21 · Question 3May/June 2021Paper 236 marks
Loading question…
Question text

3
Identify a suitable validation check that could be used for each piece of normal test data and
describe how it would be used. Each validation check must be different.
Test data for entering an email address: [email protected]
Validation check name …
Description of use …
…
…
Test data for entering a year: 2021
Validation check name …
Description of use …
…
…
Test data for entering a name: Ericson-Bower
Validation check name …
Description of use …
…
…
[6]

Advertisement
119
0478/23/M/J/21 · Question 4May/June 2021Paper 238 marks
Loading question…
Question text

4
The pseudocode algorithm should allow a user to input the number of scores to be entered and
then enter the scores. The scores are totalled, the total is output and the option to enter another
set of scores is offered.
←
0
1 Count
2 REPEAT
←
20
3
FullScore
4
INPUT Number
←
1 TO Number
5
FOR StoreLoop
6
INPUT Score
←
FullScore
7
FullScore
8
UNTIL StoreLoop = Number
9
OUTPUT "The full score is ", FullScore
10
OUTPUT "Another set of scores (Y or N)?"
11
OUTPUT Another
12
IF Another = "N"
13
THEN
←
1
14
Count
15
ENDIF
16 UNTIL Count = 1
(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) Show how you could change the algorithm to store the individual scores in the array
ScoreArray[], then find and print the average score once the scores have all been entered.
…
…
…
…
…
…
…
…
…
…

120
0478/23/M/J/21 · Question 5May/June 2021Paper 237 marks
Loading question…
Question text

5
The flowchart represents an algorithm.
The algorithm will terminate if 0 is entered at the Op input.
START
INPUT
Op
IS
No
Op = 0 ?
Yes
INPUT
Value1
INPUT
Value2
IS
Yes
Ans
Value1 + Value2
Op = 1 ?
No
END
IS
Yes
Ans
Value1 - Value2
Op = 2 ?
No
IS
Yes
Ans
Value1 * Value2
Op = 3 ?
No
IS
Yes
Ans
Value1 / Value2
Op = 4 ?
No
OUTPUT
"Input Error"
(a) Complete the trace table for the algorithm using this input data:
1, 87, 14, 3, 2, 30, 5, 10, 6, 4, 10, 2, 0, 2, 90, 6
Op
Value1
Value2
Ans
OUTPUT
[5]
(b) State the purpose of the algorithm.
…
…
…
… [1]
(c) Suggest an addition that could be made to the algorithm to make it more useful.
…
…
… [1]

Advertisement