Evaluating algorithms and test data

Two algorithms can solve the same problem but one may be far quicker or use far less memory. Good test data proves an algorithm really works.

Practise this lesson free (7 questions)

More tools

Measuring efficiency

Count the number of comparisons, the number of passes through a loop, and the memory used.
Linear search on n items: up to n comparisons.
Binary search halves the list each time, so it needs far fewer comparisons on large sorted lists.
Merge sort is faster than bubble sort on big lists but needs extra memory for the sub-lists.

Test data

TypeMeaningExample for a mark from 0 to 100
NormalTypical valid data that should be accepted56
BoundaryValid data at the very edge of the range0 and 100
ErroneousInvalid data that should be rejected"ten" or 150

Fitness for purpose

An algorithm is fit for purpose if it gives the correct output for all test data and meets the requirements.
Use logical reasoning: trace it with normal, boundary and erroneous data and compare with the expected results.
Worked example

How many comparisons does a binary search make to find 31 in [3, 8, 12, 19, 24, 31, 40]?

  1. Middle item is 19. 31 > 19, so keep the right half [24, 31, 40].
  2. Middle of that half is 31. Found.

Answer: 2 comparisons

Key idea

Efficiency is judged by comparisons, loop passes and memory. Test with normal, boundary and erroneous data. Binary search beats linear search on big sorted lists; merge sort is fast but uses more memory.

Key words
Algorithm
A precise sequence of steps to solve a problem.
Erroneous data
Invalid test data that should be rejected.
Binary
Base 2: the number system that uses only the digits 0 and 1.
Binary search
Repeatedly checks the middle item of a sorted list and discards half the list.
Linear search
Checks each item in turn from the start of a list until the target is found or the list ends.
Merge sort
Splits a list into single items, then merges pairs of lists back together in order.

All GCSE and International GCSE Computer Science key terms and definitions โ†’

Common mistakes
Quick check

Try two quick questions

See if it has sunk in. Answers are marked straight away.

Extra practice

2 more questions

Try each one, then tap to check.

  1. What is the maximum number of comparisons a linear search makes on a list of 80 items?

    Show the answer

    Answer: 80

    In the worst case the item is last or missing, so every item is checked: 80 comparisons.

  2. How many comparisons does a binary search (middle item, rounding down) make to find 40 in [3, 8, 12, 19, 24, 31, 40]?

    Show the answer

    Answer: 3

    Middle items checked: 19, 31, 40. That is 3 comparisons.

Check you have got it

Answer 7 quick questions with instant marking. If you get one wrong, GCSE-ready shows you why and gives you another go. It is free, and you do not need an account.

Video for this lesson coming soon. Subscribe on YouTube

Sources and references

Facts checked against the sources below, 17 October 2026. Last updated 2 October 2026. Spotted a mistake? Tell us and we will fix it.

What do exam command words like explain and evaluate mean? โ†’

Related lessons