Correct — produces the right output for all valid inputs
Efficient — uses minimum time and memory to complete the task
Unambiguous — each step is clear and precise; no room for interpretation
Finite — always terminates; never runs forever
Generalised — works for all valid inputs, not just specific test cases
Identifying Problems in Algorithms
Spotting Errors and Inefficiencies
When reviewing an algorithm, look for: infinite loops (no termination condition), off-by-one errors (wrong range in loops), wrong logic (incorrect conditions), and redundant steps (unnecessary calculations done more than once).
Use trace tables to step through the algorithm and check variable values at each stage
Test with boundary values — these often expose edge-case bugs
Improving Algorithms
Making Algorithms More Efficient
Remove repeated work — store results in variables rather than recalculating the same value multiple times
Early exit — stop as soon as the answer is found (e.g. bubble sort with no-swap check)
Choose better data structures — using a sorted list enables binary search instead of linear search
Use subroutines — avoid repeated code blocks; call a function instead
Exam Practice
Have a go at this question
Edexcel-style question
An algorithm searches for the largest number in a list by comparing every item twice. Describe one improvement that could be made to this algorithm.
2 marks
The algorithm should compare each item only once [1]. By keeping track of the current maximum in a variable and updating it only when a larger item is found, each comparison is done a single time — reducing the number of operations by half [1].
Key Takeaways
What to Remember
Good algorithms: correct, efficient, unambiguous, finite, generalised
Use trace tables to identify errors — especially off-by-one and logic errors
Improve algorithms: remove redundancy, add early exit, use better data structures
Always test with boundary values — edge cases often reveal hidden bugs