Big-O notation describes the limiting behaviour of a function as it tends towards infinity. Big-O notation is also used to describe the space and time complexity of an algorithm, giving an idea of the algorithm’s performance as the input size increases. A simple definition of Big-O notation is that if there exists a positive number and a real number such that
There are other, related notations given here, and are defined in a similar manner.
Notation | Basic Meaning |
---|---|
grows slower than | |
grows at the same rate of | |
grows faster than | |
grows slower than all multiples of | |
grows faster than all multiples of |
Amortized time
Amortized time instead focuses on the average time to run, rather than the worst-case performance of the algorithm. Amortized time is determined by dividing the total running time, by the number of operations and is expressed in Big-O notation. For example, if an algorithm run an arbitrary number of times runs in , then the amortized time is .