AlgorithmDesignAndProblemSolving (1)
AlgorithmDesignAndProblemSolving (1)
2 (a) An algorithm has been written in pseudocode to input 50 numbers and total only the
positive numbers.
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 only total numbers greater than 0
and less than 20.
...................................................................................................................................................
...................................................................................................................................................
......................................................................................................................................[2]
This flowchart inputs the type of passenger for a survey: S for Senior, A for Adult, C for Child.
All other values are ignored, apart from Z which ends the process.
[5]
5 A programmer restricts input values to less than 90 and greater than 60.
(a) State whether this is called validation or verification.
...................................................................................................................................................
...................................................................................................................................................[2]
(b) State three different types of test data the programmer would need to use. Give an
example of each type and the reason that the programmer chose that test data.
Type 1 .......................................................................................................................................
Example ....................................................................................................................................
Reason .....................................................................................................................................
...................................................................................................................................................
Type 2 .......................................................................................................................................
Example ....................................................................................................................................
http://SirRazaAcademy.com
Compiled by S.M.Raza 3
Topical Past Papers – Algorithm design and problem solving IGCSE 0478 /O-Level 2210
Reason .....................................................................................................................................
...................................................................................................................................................
Type 3 .......................................................................................................................................
Example ....................................................................................................................................
Reason .....................................................................................................................................
...................................................................................................................................................[9]
June 2019 Paper 21, question 4
[3]
http://SirRazaAcademy.com
Compiled by S.M.Raza 4
Topical Past Papers – Algorithm design and problem solving IGCSE 0478 /O-Level 2210
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]
3 This flowchart inputs the marks gained in an examination. An input of –1 ends the
routine.
Complete the trace table for the mark input data: 50, 70, 65, 30, 95, 50, 55, 85, 65, 35, –1, 45
[4]
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.
Find the four errors in the pseudocode and suggest a correction for each error.
Error 1 .......................................................................................................................................
...................................................................................................................................................
Correction .................................................................................................................................
...................................................................................................................................................
Error 2 .......................................................................................................................................
...................................................................................................................................................
Correction .................................................................................................................................
http://SirRazaAcademy.com Compiled by S.M.Raza 8
Topical Past Papers – Algorithm design and problem solving IGCSE 0478 /O-Level 2210
...................................................................................................................................................
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.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
..................................................................................................................................... [4]
4 For each of the four checks in the table, place a tick in the correct column to show whether it
is an example of a validation or verification check.
Double entry
Check digit
Presence check
[4]
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.
Trace table 1
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.
4 (a) Complete the trace table for this algorithm using the given input data.
[6]
2 An algorithm has been written in pseudocode to select a random number using the function
RandInt(n), which returns a whole number between 1 and the argument n. The algorithm then
allows the user to guess the number.
Find the four errors in the pseudocode and suggest a correction to remove each error.
Error 1 ..............................................................................................................................................
Correction
.........................................................................................................................................
Error 2 ..............................................................................................................................................
Correction
.........................................................................................................................................
..........................................................................................................................................................
Error 3 ..............................................................................................................................................
Correction .........................................................................................................................................
..........................................................................................................................................................
Error 4 ..............................................................................................................................................
Correction .........................................................................................................................................
..........................................................................................................................................................[4]
Nov 2019 Paper 22 question 3
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.
[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]
5 The algorithm performs an operation on the array named MyData DIV means integer division,
so only the whole number part of the result is returned
e.g. 7 DIV 2 returns a value of 3
6 Draw four different flowchart symbols and describe how they are used in a program
flowchart.
2 Most programming languages include basic data types. Ahmad is describing the basic data
types he has used.
State the data type that Ahmad is describing in each sentence.
Choose the data type from this list of programming terms.
A number with a fractional part that can be positive or negative and used in calculations
Data type .......................................................................................................................................
A whole number that can be positive, negative or zero and used in calculations
Data type .......................................................................................................................................
A single number, symbol or letter
Data type .......................................................................................................................................
A sequence of characters
Data type .......................................................................................................................................
A data type with two values, True or False
Data type ...................................................................................................................................[5]
3 (a) An algorithm has been written in pseudocode to input the names and marks of 35
students.
The algorithm stores the names and marks in two arrays Name[ ] and Mark[ ]. The highest
mark awarded is found and the number of students with that mark is counted. Both of these
values are output.
Give line numbers where the four errors are to be found in the pseudocode. Suggest a
correction for each error.
(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.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
......................................................................................................................................[6]
4 This flowchart inputs the points won and the points lost when playing a game. The difference
between the points won and lost is calculated and depending on the result the player can:
move up to the next level, stay at the same level, or move down to the previous level. The
flowchart finishes when the input for points won is –1.
5000, 4474, 6055, 2000, 7900, 9800, 3000, 2150, –1, 6700, 7615
[3]
(b) The flowchart needs to be changed. When the difference is more than 5000 the output
message is ‘Fantastic leap up two levels’.
Describe the changes that will need to be made to the flowchart.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
......................................................................................................................................[3]
2 Tick () one box in each row to identify if the statement is about validation,
verification or both.
Statement Validation Verification Both
() () ()
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]
3 Name and describe the most appropriate programming data type for each of the examples of
data given. Each data type must be different.
Data: 37
Data type name ............................................................................................................................
Data type description ...................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
Data: Cambridge2021
Data type name ............................................................................................................................
Data type description ..................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
Data: 47.86
Data type name ...........................................................................................................................
Data type description ..................................................................................................................
.......................................................................................................................................................
..................................................................................................................................................[6]
June 2020 Paper 21 question 4
4 The pseudocode algorithm shown has been written by a teacher to enter marks for the
students in her class and then to apply some simple processing.
Compiled by S.M.Raza 21
Topical Past Papers – Algorithm design and problem solving IGCSE 0478 /O-Level 2210
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
..................................................................................................................................... [3]
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
..................................................................................................................................... [3]
(c) Describe how you could change the algorithm to allow teachers to use it with any size of
class.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
......................................................................................................................................[3]
(b) State the type of each pseudocode statement. For example, X ← X + Y is totalling. IF
Number = 20 ................................................................................................................... PRINT
Number ........................................................................................................................ Number
(a) Complete the trace table for the algorithm using this input data:
Secret, Secret, VerySecret, VerySecret, Pa55word, Pa55word, 999, 888
[3]
(b) Explain how the algorithm could be extended to allow three attempts at inputting the
matching password. Any pseudocode statements used in your answer must be fully explained.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
......................................................................................................................................[4]
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.
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.
Correction .....................................................................................................................................
.......................................................................................................................................................
Error 2 line number .......................................................................................................................
Correction .....................................................................................................................................
.......................................................................................................................................................
Error 3 line number .......................................................................................................................
Correction .....................................................................................................................................
...................................................................................................................................................[6]
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.
Complete the trace table for the algorithm using the input data:
5, 6, 8, 0, 11, 13
Flag Number Divisor Value OUTPUT
[5]
6 Draw the flowchart symbol for Decision and the flowchart symbol for Process.
Decision Process
[2]