Identify and correct algorithm errors
Compare an algorithm with its requirement, find the faulty condition or update and retest the correction.
Exam scope and assessment notes
This sequence follows Cambridge IGCSE Computer Science 0984, 2026–2028 syllabus Version 4. It covers subject content Topic 7 only. The separately published 2029–2031 syllabus is not mapped here. Practice is original, self-checked and does not award an official Cambridge grade. Full timed papers and human subject-teacher review remain outstanding. Cambridge states that 0984 has the same 2026–2028 subject content as 0478, with 9–1 grading. In June and November, Cambridge lists 0984 in Administrative zone 3 and for centres in Oman and the UAE. Confirm availability for your centre and exam series with Cambridge International. The separately published 2029–2031 syllabus changes to Python 3 only and removes pseudocode; this 2026–2028 route does not cover those changes.
Before you begin
- No programming language is required. Be comfortable with place value and multiplication; each lesson introduces the computer-science notation it uses.
Work on paper. Try each question before revealing help, and explain why your method works.
Quick readiness check
If a loop should process values 1 through 5 but stops at 4, what kind of issue is likely?
What you will learn
- Detect logic and boundary errors
- Suggest a precise correction
- Use test data to confirm the amendment
Errors are differences between intended and actual behaviour
An algorithm may be syntactically clear but logically wrong. Compare each condition and update with the requirement; check initial values, loop endpoints, variable names and the order of operations.
Apply and check the rule
After suggesting a correction, dry-run it with data that exposed the fault and with other representative or boundary values. One successful example does not prove that all branches work.
Pause and explain
A correction fixes one example but has not been tested at the boundary. What remains uncertain?
Worked example
A routine should count values above 10 but uses IF Value < 10 THEN Count ← Count + 1. Correct it.
Show the worked solution
- The comparison points in the wrong direction.
- Use Value > 10 for values strictly above 10.
- Test a value below, equal to and above 10.
Answer Change the condition to Value > 10, then test 9, 10 and 11.
Try a topic test
Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.
Test this topic →From guided practice to a new situation
Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.
A routine should reject quantities below 1 but uses IF Quantity > 1 THEN Reject. Identify the boundary error and correct it.
Give me a hint
The condition must include every value below the minimum.
Compare my reasoning
- Values 0 and negative should be rejected.
- The current condition rejects valid values above 1.
- Use IF Quantity < 1 THEN Reject.
Use Quantity < 1 to reject values below the allowed minimum; test 0, 1 and 2.
Look for these in your work
- Fault
- Correct inequality
- Boundary tests
An average routine divides by Count before checking whether Count is zero. Explain the error and suggest a safe order.
Give me a hint
Division must only occur when there are values.
Compare my reasoning
- Count may be zero.
- Dividing by zero is invalid.
- Check Count > 0 before calculating and otherwise report no data.
Test Count first; calculate Total/Count only when Count > 0, otherwise report that no average is available.
Look for these in your work
- Risk
- Guard
- Alternative
A search routine returns the target position for a list containing duplicates. The requirement asks for the first occurrence, but the routine continues to the end. Explain how to amend and test it.
Give me a hint
The algorithm should stop on the earliest match.
Compare my reasoning
- Return or store the position when the first equality occurs.
- Do not overwrite it with later matches.
- Test a list with two copies and confirm the earlier position is returned.
Stop the linear search at the first match, then test a list containing duplicates to verify the earliest position is returned.
Look for these in your work
- Requirement
- Amendment
- Discriminating test
Common mistakes
- Changing an algorithm without identifying the requirement it violates
- Testing only the case that previously passed
What can you explain now?
What should follow a proposed algorithm correction?
Compare with the explanation
Retest the amended algorithm
Testing confirms whether the correction fixes the observed behaviour and preserves other cases.
After trying it yourself, choose your next review. This is your self-assessment.
Your review choice appears on Today. Sign in to sync it across devices.
Make it stick
How do you identify an algorithm error and verify the correction?
If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.