Learn in your language
Skip to content
IGCSE · Cambridge (CIE) · 0478

Identify and correct algorithm errors

Compare an algorithm with its requirement, find the faulty condition or update and retest the correction.

Cambridge IGCSE Computer Science 0478 · Algorithm design and problem-solving · 2026–2028 Version 6 · 7

This sequence follows Cambridge IGCSE Computer Science 0478, 2026–2028 syllabus Version 6. 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.

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?

Put the idea to work

Worked example

A routine should count values above 10 but uses IF Value < 10 THEN Count ← Count + 1. Correct it.

Show the worked solution
  1. The comparison points in the wrong direction.
  2. Use Value > 10 for values strictly above 10.
  3. 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.

1 · Guided

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
  1. Values 0 and negative should be rejected.
  2. The current condition rejects valid values above 1.
  3. 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
2 · Independent

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
  1. Count may be zero.
  2. Dividing by zero is invalid.
  3. 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
3 · Transfer

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
  1. Return or store the position when the first equality occurs.
  2. Do not overwrite it with later matches.
  3. 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
Recall without your notes

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.

Keep learning Computer Science

Course scope and assessment

165 original lessons map the listed objectives across all 10 main topics in the 2026–2028 Version 6 syllabus, with worked explanations and guided, independent and transfer practice. This is mapped teaching coverage, not proof of full exam readiness. Three earlier starter lessons remain available but are not counted as syllabus-mapped teaching. Practical programming experience in an executable browser workspace, full timed-paper practice, human subject-teacher review and the separate 2029–2031 syllabus remain outstanding. Practice is self-checked and does not award an official Cambridge grade.

StudyForA · Learn with understanding

Original teaching content and links to official sources. Check your exam year and qualification before using a resource.