Asymptotic analysis
suggest changeWhen several algorithms can sort an array, you need to know which one will do its job. Asymptotic analysis describes how an algorithm’s cost grows with the input size n. In computer science that growth is usually written in Big O notation.
- Linear time O(n): The function does work proportional to the number of elements, so it gets slower as that number increases. Its running time depends on its input size.
- Polynomial time, for example O(n²): The work grows as a polynomial of
n. Nested loops are a common cause: two nested loops are often O(n²), and three are often O(n³). This is not exponential time (such as O(2ⁿ)), which grows much faster. - Logarithmic time O(log n): The work grows with the logarithm of
n, so it increases slowly as the input grows. Programmers often aim for this kind of bound.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents