Measures and methods to determine the efficiency of different algorithms, Big O notation (constant, linear, polynomial, exponential and logarithmic complexity).
2.3.1 Algorithms
Algorithms — Note 3 of 6
Candidates need to understand how the efficiency of an algorithm is measured using Big O notation, including constant, linear, polynomial, exponential and logarithmic complexity. Candidates need to be able to recognise and draw each complexity on a graph and read and write the notation.
Big O notation describes how the time (or space) an algorithm needs grows as the input size grows, ignoring constant factors. It lets algorithms be compared independently of the hardware they run on.
A way of expressing the upper bound of an algorithm's time or space complexity as a function of the input size n.
O(1) < O(log n) < O(n) < O(n log n) < O(n^2) < O(2^n)
n = 1,000:
O(log n) ~ 10 steps
O(n) 1,000 steps
O(n log n) ~ 10,000 steps
O(n^2) 1,000,000 steps
O(2^n) more steps than atoms in the universe