Algorithms - EdexcelTesting and evaluating an algorithm

Algorithms are step-by-step plans for solving problems. Algorithms can be designed using pseudo-code, flowcharts, written descriptions and program code. There are also some standard algorithms for searching and sorting.

Part ofComputer SciencePrinciples of computer science

Testing and evaluating an algorithm

Algorithms should run as efficiently as possible. Testing and evaluating them ensures that they run correctly, quickly and without wasting memory.

Logical reasoning

When thinking about an algorithm step-by-step, the user needs to check if it produces the correct output for all of its inputs, for example, does it follow the right sequence of steps?

Test data

To check an , the user can input a variety of test data to check that it works correctly. This should include:

  • normal data – testing typical data that is likely to be input, such as the value 15 for age
  • boundary data – valid or invalid data on the boundary of what it should accept, for example, the value 1 or 100 for an input of percentage for a test score
  • erroneous data – testing invalid data that the program should not accept such as 30/02/2025 for a date when there were only 28 days in February.

Measuring efficiency

There are different ways to measure efficiency of algorithms:

  • number of comparisons - check how many times the algorithm compares values. If there are fewer comparisons, then the program will be faster
  • number of passes through a loop - count how many times a loop repeats. If there are fewer passes through a loop, then the algorithm will be more efficient
  • use of memory - some algorithms use more memory than others. For example, the bubble sort only uses one list but the merge sort uses multiple copies of the list. If less memory is used, then there is a more efficient use of resources.