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

199 questions · page 9 of 14 · Clear filters

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

3
This pseudocode algorithm calculates the weight and number of bags in a load of firewood. The
weight in kilograms of each bag is input. The algorithm finishes when either 50 bags have been
weighed, or as soon as the total weight exceeds 1000 kilograms. Only then are the total weight
and the number of bags in the load output.
←
1000
01
TotalWeight
←
0
02
BagCount
←
50
03
MaxBag
←
1000
04
MaxWeight
05
REPEAT
06
OUTPUT "Please Enter weight of bag"
07
INPUT Weight
←
TotalWeight + Weight
08
TotalWeight
←
BagCount + 1
09
BagCount
10
OUTPUT "Number of bags in the load is ", BagCount
11
UNTIL TotalWeight > MaxWeight AND BagCount >= MaxBag
12
OUTPUT "Total weight of the load is ", MaxWeight
(a) Give the line number(s) from the algorithm of:
an assignment statement …
a loop …
a counting statement …
a totalling statement …
[4]
(b) Give the line numbers of the four errors in this pseudocode. 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 …
…
[4]
(c) Explain how you could extend the algorithm to calculate and display the average weight of a
bag of firewood in the load.
…
…
…
…
…
…

122
0478/21/O/N/20 · Question 4Oct/Nov 2020Paper 216 marks
Loading question…
Question text

4
This flowchart inputs five numbers and performs a calculation.
The predefined function MOD finds the remainder from integer division for example
←
25 MOD 11 gives R a value of 3
R
START
INPUT
V,W,X,Y,Z
Yes
IS
END
V = 0 ?
No
← V*2 + W*3 + X*4 + Y*5
A
← A MOD 11
B
Yes
IS
OUTPUT
B = Z ?
"Valid"
No
OUTPUT
"Invalid"
(a) Complete the trace table for this set of input data:
5, 4, 6, 2, 1, 9, 3, 2, 1, 6, 7, 6, 1, 5, 1, 0, 0, 0, 0, 0
V
W
X
Y
Z
A
B
OUTPUT
[4]
(b) Describe the purpose of this flowchart.
…
…
…
… [2]

123
0478/22/O/N/20 · Question 3Oct/Nov 2020Paper 226 marks
Loading question…
Question text

3
This pseudocode algorithm is used as a validation check.
PRINT "Input a number from 1 to 5000"
REPEAT
INPUT Number
IF Number < 1 OR Number > 5000
THEN
PRINT "Invalid number, please try again"
ENDIF
UNTIL Number >= 1 AND Number <= 5000
PRINT Number, " is within the correct range"
Identify three different types of test data. For each type, give an example of the test data you
would use to test this algorithm and state a reason for your choice of test.
Type of test data 1 …
Test data …
Reason …
…
Type of test data 2 …
Test data …
Reason …
…
Type of test data 3 …
Test data …
Reason …
…
[6]

Advertisement
124
0478/22/O/N/20 · Question 5Oct/Nov 2020Paper 2227 marks
Loading question…
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]

125
0478/22/O/N/20 · Question 6Oct/Nov 2020Paper 222 marks
Loading question…
Question text

6
Draw a flowchart symbol to represent each of the following:
Input/Output
Decision
[2]
Question 7 starts on Page 12.
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of the University of

126
0478/21/M/J/20 · Question 2May/June 2020Paper 212 marks
Loading question…
Question text

Tick ( ü ) one box in each row to identify if the statement about structure diagrams is true or false.
2
False
True
Statement
( ü )
( ü )
A structure diagram is a piece of code that is available throughout the
structure of a program.
A structure diagram shows the hierarchy of a system.
A structure diagram is another name for an array.
A structure diagram shows the relationship between different components
of a system.
[2]

127
0478/21/M/J/20 · Question 3May/June 2020Paper 217 marks
Loading question…
Question text

3
Programs can perform validation and verification checks when data is entered.
(a) Give the names of two different validation checks and state the purpose of each one.
Check 1 …
Purpose …
…
…
Check 2 …
Purpose …
…
…
[4]
(b) Give the name of one verification check.
… [1]
(c) Describe the difference between validation and verification.
…
…
…
… [2]

128
0478/21/M/J/20 · Question 5May/June 2020Paper 216 marks
Loading question…
Question text

5
The flowchart represents an algorithm.
The predefined function DIV gives the value of the result of integer division,
←
9 DIV 4 gives y a value of 2
for example, y
An input value of –1 ends the algorithm.
START
INPUT
Value
IS
Yes
Value =
-1 ?
No
Calc1
Value DIV 2
Calc2
Value DIV 3
IS
No
Calc1 =
Value / 2 ?
Yes
IS
No
Calc2 =
Value / 3 ?
Yes
OUTPUT
Value
END
(a) Complete the trace table for the input data:
50, 33, 18, 15, 30, –1, 45, 12, 90, 6
Value
Calc1
Calc2
OUTPUT
[4]
(b) Describe the purpose of the algorithm.
…
…
… [2]

Advertisement
129
0478/22/M/J/20 · Question 18May/June 2020Paper 2225 marks
Loading question…
Question text

18
OUTPUT "There are ", HighestMarkStudents," with the highest mark of ",
HighestMark
Give line numbers where the four errors are to be found in the pseudocode. 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 …
…
[4]
(b) Explain how you could extend the algorithm to also find the lowest mark awarded, count the
number of students with that mark, and output both these values.
…
…
…
…
…
…
…
…
…
…
…
…
…

130
0478/23/M/J/20 · Question 2May/June 2020Paper 234 marks
Loading question…
Question text

2
Draw a line to connect each Description to the most appropriate Pseudocode example.
Description
Pseudocode example
A loop that will iterate
CASE … OF … OTHERWISE … ENDCASE
at least once
A loop that will not be
Number + 1
Number
executed on the first test
if the condition is false
WHILE … DO … ENDWHILE
A conditional statement
Sum
Sum + NewValue
Totalling
REPEAT … UNTIL
Counting
[4]

131
0478/23/M/J/20 · Question 3May/June 2020Paper 236 marks
Loading question…
Question text

3
This section of pseudocode is to be used as a validation check that will continue until a number
between 0 and 499 inclusive is entered.
1
PRINT "Input a number from 0 to 499 inclusive"
1 TO 10
2
FOR Number
3
INPUT Number
4
IF Number < 0 AND Number > 499
5
THEN
6
PRINT "Invalid number, please try again"
7
ENDIF
8
UNTIL Number = 0 OR Number = 499
9
PRINT Number, " is within the correct range"
There are three lines in this pseudocode that contain errors. In each case, state the line number
to identify the incorrect line and write out the corrected line in full.
Error 1 line number …
Correction …
…
Error 2 line number …
Correction …
…
Error 3 line number …
Correction …
…
[6]

132
0478/23/M/J/20 · Question 4May/June 2020Paper 236 marks
Loading question…
Question text

4
A code must take the form LL9 9LL where L is a letter and 9 is a digit.
(a) A presence check has already been used to ensure data has been entered. Name two other
types of validation check that can be used to test the code is valid.
Check 1 …
Check 2 …
[2]
(b) Give one example of invalid test data for each of the validation checks you have named in
part (a) and in each case, give a reason why it fails the check. Each example of test data
must be different.
Check 1 Invalid Test Data …
…
Reason …
…
…
…
Check 2 Invalid Test Data …
…
Reason …
…
…
…
[4]

133
0478/23/M/J/20 · Question 6May/June 2020Paper 232 marks
Loading question…
Question text

6
Draw the flowchart symbol for Decision and the flowchart symbol for Process.
Decision
Process
[2]

Advertisement
134
0478/22/F/M/20 · Question 3Feb/March 2020Paper 228 marks
Loading question…
Question text

3
This flowchart inputs student percentage marks for three examinations. If the average of these
marks is 80% or over then a distinction grade is awarded. If the average of these marks is less
than 40% then a fail grade is awarded. Otherwise a pass grade is awarded.
START
INPUT
Mark1,Mark2,Mark3
Total
Mark1 +
Mark2 + Mark3
Average
Total / 3
IS
OUTPUT
Yes
Average >= 80 ?
"Distinction"
No
IS
Yes
OUTPUT
Average < 40 ?
"Fail"
No
OUTPUT
"Pass"
END
(a) Complete a trace table for each set of input data:
Set 1: 88, 74, 60
Total
Average
Mark1
Mark2
Mark3
OUTPUT
Set 2: 20, 33, 67
Total
Average
Mark1
Mark2
Mark3
OUTPUT
Set 3: 79, 91, 70
Total
Average
Mark1
Mark2
Mark3
OUTPUT
[5]
(b) It has been decided to include an extra grade of Merit when the average of the marks is 60%
or more, and less than 80%. Describe the changes that will need to be made to the flowchart.
…
…
…
…
…
…
…
… [3]

135
0478/22/F/M/20 · Question 4Feb/March 2020Paper 224 marks
Loading question…
Question text

4
Explain why validation and verification checks are needed when data is input.
Include an example of each type of check in your answer.
…
…
…
…
…
…
…
…
… [4]
Question 5 starts on page 14.

Advertisement