EXAM QUESTIONS · IGCSE 0478
Algorithm Design Exam-Style Questions with Answers (IGCSE 0478)
Original exam-style questions on abstraction, trace tables, validation and verification, test data, finding errors, bubble sort, flowcharts and writing algorithms for Cambridge IGCSE Computer Science 0478 (Paper 2). There are 34 marks in total. Try each question on paper first, then press Show answer to see the mark scheme. Some answers mark themselves.
Describe what is meant by:
- abstraction [1]
- decomposition [1]
Show answer
- Removing unnecessary details so you can focus on what is important for solving the problem. [1]
- Breaking a problem down into smaller sub-problems that are easier to solve. [1]
Complete a trace table for this algorithm using the input data 12, 5, 20, 10, 15.
Total ← 0
Count ← 0
FOR Index ← 1 TO 5
INPUT Number
IF Number > 10
THEN
Total ← Total + Number
Count ← Count + 1
ENDIF
NEXT Index
OUTPUT Total, CountDraw your trace table on paper, then type the final values to check them.
Show answer
| Index | Number | Total | Count | OUTPUT |
|---|---|---|---|---|
| 0 | 0 | |||
| 1 | 12 | 12 | 1 | |
| 2 | 5 | |||
| 3 | 20 | 32 | 2 | |
| 4 | 10 | |||
| 5 | 15 | 47 | 3 | 47, 3 |
- 1 mark: Total and Count start at 0
- 1 mark: Index 1 to 5 with the correct Number values
- 1 mark: Total correct (12, 32, 47); 10 is not added because 10 is not greater than 10
- 1 mark: Count correct and OUTPUT 47, 3
A school website asks students to enter some data. State the most suitable validation check for each item.
- Age, which must be from 11 to 18 [1]
- Email address, which must be entered [1]
- A student code, which must be exactly 6 characters long [1]
Show answer
- Range check [1]
- Presence check [1] (a format check is also accepted for checking it contains an @)
- Length check [1]
- Explain the difference between validation and verification. [2]
- Describe one method of verification. [1]
Show answer
- Validation is an automatic check that data is reasonable / follows set rules. [1]
- Verification checks that data has been entered or copied correctly from the original. [1]
- Any one: double entry – the data is entered twice and the two entries are compared; visual check – the user compares the data on screen with the original. [1]
A program accepts whole numbers from 1 to 100 inclusive. Give an example of each type of test data.
- Normal [1]
- Abnormal [1]
- Extreme [1]
- Boundary [1]
Show answer
- Normal: any value from 2 to 99, e.g. 50 [1]
- Abnormal: any value that should be rejected, e.g. −7, “ten” or 150 [1]
- Extreme: the largest or smallest valid value, 1 or 100 [1]
- Boundary: a pair either side of a limit, e.g. 100 and 101 or 0 and 1 [1]
This algorithm should input 10 numbers and output the largest. It contains three errors.
Largest ← 0
FOR Count ← 0 TO 10
INPUT Num
IF Num < Largest
THEN
Largest ← Num
ENDIF
NEXT Count
OUTPUT NumIdentify each error and write the correction.
Show answer
1 mark for each error identified and 1 mark for each correction: [6]
- FOR Count ← 0 TO 10 inputs 11 numbers → FOR Count ← 1 TO 10
- IF Num < Largest finds the smallest → IF Num > Largest
- OUTPUT Num outputs the last number → OUTPUT Largest
Tip: setting Largest ← 0 only works if all the numbers are positive. A safer method is to set Largest to the first number input.
A bubble sort is used to sort this list into ascending order:
5, 3, 8, 1, 9, 2
- Write the list after the first pass. [2]
- State how the algorithm knows that the list is sorted. [1]
Show answer
- 3, 5, 1, 8, 2, 9 [2]
Each pair is compared and swapped if needed: 5↔3, 8↔1, 9↔2. The largest value (9) ends up at the end. - A complete pass is made with no swaps. [1]
State the purpose of each flowchart symbol.
- A diamond (decision) [1]
- A rounded rectangle (terminator) [1]
Show answer
- Shows a question or condition with two possible outcomes (Yes/No), so the algorithm can take different paths. [1]
- Shows the start or end of the algorithm. [1]
Write an algorithm in pseudocode that:
- inputs 20 temperatures
- calculates the average temperature
- outputs the average.
Show answer
Total ← 0 FOR Count ← 1 TO 20 OUTPUT "Enter temperature ", Count INPUT Temperature Total ← Total + Temperature NEXT Count Average ← Total / 20 OUTPUT "Average temperature: ", Average
- 1 mark: total initialised to 0
- 1 mark: loop that runs 20 times
- 1 mark: input inside the loop
- 1 mark: running total updated inside the loop
- 1 mark: average calculated after the loop and output
Explain why a REPEAT … UNTIL loop is often used to validate input.
Show answer
- The condition is checked at the end, so the loop always runs at least once / the user is always asked for the input. [1]
- It keeps asking until the input is valid, so invalid data cannot get through. [1]
Frequently asked questions
How do you complete a trace table in IGCSE Computer Science?
Write a column for each variable and the output. Go through the algorithm one line at a time and write a new value in the column each time a variable changes.
What is the difference between extreme and boundary test data?
Extreme data is the largest or smallest value that should be accepted. Boundary data tests both sides of a limit: one value that should be accepted and one that should be rejected.
Are these past paper questions?
No. These are original exam-style questions written by a Computer Science teacher in the Cambridge style.
Revise the topic: IGCSE algorithm design notes · Linear search and bubble sort guide · Validation and verification guide · 15-mark question guide · All exam-style questions