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

199 questions · page 10 of 14 · Clear filters

0 / 0Answer a question to start your score.
Quick quiz (10)Saved 0
Advertisement
136
0478/21/O/N/19 · Question 2Oct/Nov 2019Paper 214 marks
Loading question…
Question text

2
For each of the four descriptions in the table, place a tick in the correct column to show whether it
describes a Structure diagram, a Flowchart or Library routines.
Structure
Library
Description
diagram
Flowchart
routines
A modelling tool used to show the hierarchy of a
system.
A collection of standard programs available for
immediate use.
A graphical representation used to represent an
algorithm.
A graphical representation to show how a system is
broken into sub-systems.
[4]

137
0478/21/O/N/19 · Question 3Oct/Nov 2019Paper 2111 marks
Loading question…
Question text

3
Examine the following pseudocode:
INPUT A
INPUT B
INPUT C
INPUT D
INPUT E
INPUT F
INPUT G
INPUT H
INPUT I
INPUT J
INPUT K
INPUT L
A + B + C + D + E + F + G + H + I + J + K + L
T
OUTPUT "The average equals ", T / 12
(a) Describe what happens in this pseudocode.
…
…
…
…
…
… [3]
(b) Describe how this pseudocode could be altered to allow any number of values to be input.
…
…
…
…
…
…
…
… [3]
(c) Re-write the given pseudocode to allow any number of values to be input.
…
…
…
…
…
…
…
…
…
…
..

138
0478/21/O/N/19 · Question 4Oct/Nov 2019Paper 2135 marks
Loading question…
Question text

4
(a) Complete the trace table for this algorithm using the given input data.
0
Index
0 TO 7
FOR Count
INPUT Value
IF Value > 50
THEN
Value
PassMarks[Index]
Index + 1
Index
ENDIF
NEXT Count
PRINT "Number passed ", Index
Input data: 58, 40, 67, 85, 12, 13, 75, 82
PassMarks
OUTPUT
Index Count Value [0] [1] [2] [3] [4] [5] [6] [7]
[6]
(b) Give the purpose of the algorithm shown in part (a).
…
…
… [1]

Advertisement
139
0478/22/O/N/19 · Question 3Oct/Nov 2019Paper 227 marks
Loading question…
Question text

3
(a) The flowchart checks the lengths of a batch of 10 ropes. For the batch to be accepted 90% of
the lengths need to be between 24.9 and 25.1 metres.
START
Reject
0
Count
0
Yes
Is Count =
10 ?
No
No
Is Reject
Count
Count + 1
<= 1 ?
INPUT Length
Yes
OUTPUT "Batch
rejected"
Is Length <
Yes
25.1 AND
Length > 24.9 ?
No
Reject
Reject + 1
OUTPUT "Batch
accepted"
END
Complete the trace table for the input data:
24.88, 25.01, 24.98, 25.00, 25.05, 24.99, 24.97, 25.04, 25.19, 25.07
Reject
Count
Length
OUTPUT
[4]
(b) (i)
It has been decided to only reject batches of rope that contain ropes that are too short.
State the change required to the algorithm.
…
… [1]
(ii)
Explain how the algorithm to reject batches could be improved to make it more effective.
…
…
…
… [2]

140
0478/22/O/N/19 · Question 4Oct/Nov 2019Paper 223 marks
Loading question…
Question text

4
Four validation checks and four descriptions are shown.
Draw a line to connect each validation check to the correct description.
Validation Check
Description
Checks that some data is entered.
Range check
Checks for a maximum number of characters
Presence check
in the data entered.
Checks that the characters entered are all
Length check
numbers.
Checks that the value entered is between an
Type check
upper value and a lower value.
[3]

141
0478/22/O/N/19 · Question 5Oct/Nov 2019Paper 224 marks
Loading question…
Question text

5
A programmer writes a program to weigh baskets of fruit in grams, keeping a total of the weight
and counting the number of baskets. The total weight is stored in a variable Total and the number
of baskets is stored in a variable BasketCount.
Explain, including examples of programming statements, how totalling and counting could be used
in this program.
Totalling …
…
…
…
…
…
Counting …
…
…
…
…
…
[4]

142
0478/23/O/N/19 · Question 3Oct/Nov 2019Paper 233 marks
Loading question…
Question text

3
Name the three types of loop structure used in pseudocode.
…
…
…
…
…
… [3]

143
0478/23/O/N/19 · Question 6Oct/Nov 2019Paper 234 marks
Loading question…
Question text

6
Draw four different flowchart symbols and describe how they are used in a program flowchart.
Flowchart symbol
Description of use
[4]

Advertisement
144
0478/21/M/J/19 · Question 3May/June 2019Paper 214 marks
Loading question…
Question text

3
(a) Give an example of a conditional statement using pseudocode.
…
…
…
…
… [2]
(b) Describe the purpose of a conditional statement.
…
…
…
… [2]
Question 4 starts on page 10.

145
0478/21/M/J/19 · Question 4May/June 2019Paper 2111 marks
Loading question…
Question text

4
This section of program code may be used as a validation check.
1
PRINT "Input a value between 0 and 100 inclusive"
2
INPUT Value
3
WHILE Value < 0 OR Value > 100
4
PRINT "Invalid value, try again"
5
INPUT Value
6
ENDWHILE
7
PRINT "Accepted: ", Value
(a) Give a name for this type of validation check.
… [1]
(b) Describe what is happening in this validation check.
…
…
…
…
…
…
…
… [2]
(c) Complete the trace table for this program code using the test data: 200, 300, –1, 50, 60
Value
OUTPUT
[3]
(d) Draw a flowchart to represent this section of program code.
[5]

146
0478/22/M/J/19 · Question 2May/June 2019Paper 228 marks
Loading question…
Question text

2
(a) An algorithm has been written in pseudocode to input 100 numbers, select and print the
largest number and smallest number.
1
Count
INPUT Number
Number
High
Count
Low
REPEAT
INPUT Number
IF Number > High
THEN
Number
High
ENDIF
IF Number > Low
THEN
Number
Low
ENDIF
Count + 1
Count
UNTIL Count > 99
PRINT "Largest Number is ", Number
PRINT "Smallest Number is ", Low
Find 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 would change the corrected algorithm to total the numbers and print the total.
Use a variable Total.
…
…
…
…
…
…
…
… [4]

147
0478/22/M/J/19 · Question 3May/June 2019Paper 224 marks
Loading question…
Question text

3
This flowchart inputs the marks gained in an examination. An input of –1 ends the routine.
START
Total
0
Count
0
Distinction
0
INPUT Mark
Yes
Is Mark = –1 ?
Total
Total + Mark
Count
Count + 1
No
OUTPUT "Number of
No
Is
Distinctions ", Distinction
Mark >=
OUTPUT "Average Mark "
80 ?
Total/Count
Yes
END
Distinction
Distinction + 1
Complete the trace table for the mark input data: 50, 70, 65, 30, 95, 50, 55, 85, 65, 35, –1, 45
OUTPUT
Total
Count
Distinction
Mark
[4]

148
0478/22/M/J/19 · Question 5May/June 2019Paper 226 marks
Loading question…
Question text

5
Explain what is meant by validation and verification.
Give an example for each one.
Validation …
…
…
…
Example …
…
…
Verification …
…
…
…
Example …
…
…
[6]

Advertisement
149
0478/23/M/J/19 · Question 2May/June 2019Paper 238 marks
Loading question…
Question text

2
(a) An algorithm has been written in pseudocode to input the weight of 500 items and reject any
that are over-weight or under-weight, then print the percentage rejected.
1
Count
0
Reject
62
Over
58
Under
REPEAT
INPUT ItemWeight
IF ItemWeight > Over AND ItemWeight < Under
THEN
Reject - 1
Reject
ENDIF
Count + 1
Count
UNTIL Count > = 500
Reject / 100
Reject
PRINT "Percentage rejected is ", Reject
Find 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 would change the corrected algorithm to calculate the number accepted
instead of rejected, using a variable Accept, and print a warning if fewer than 50% are
accepted.
…
…
…
…
…
…
…

150
0478/23/M/J/19 · Question 3May/June 2019Paper 234 marks
Loading question…
Question text

3
This flowchart inputs the tread depth of five tyres, four on the car and a spare tyre. Any tread
depth of 1.6 mm or less is rejected. To be potentially roadworthy, a car must have four tyres with a
tread depth greater than 1.6 mm.
START
TreadReject
0
Count 1
Is
Yes
Count = 6?
Count
Count + 1
No
Is
No
INPUT Depth
TreadReject
<= 1?
Yes
OUTPUT "Car is
not roadworthy"
No
Is
Depth <=
1.6?
Yes
TreadReject
TreadReject + 1
OUTPUT "Car is
potentially
roadworthy"
END
Complete Trace table 1 for the tread depth input data:
1.7, 1.9, 1.4, 1.8, 2.0
TreadReject
Count
Depth
OUTPUT
Trace table 1
Complete Trace table 2 for the tread depth input data:
1.2, 1.9, 1.4, 1.8, 2.4
TreadReject
Count
Depth
OUTPUT
Trace table 2
[4]

Advertisement