Introduction to Asymptotic Analysis and Big O
In this lesson, you will learn about asymptotic notation, it is an important tool applied to the analysis of algorithms.
You have seen that the time complexity of an algorithm can be expressed as polynomial. To compare two algorithms, you can compare the respective polynomials. However, the analysis performed in the previous lessons is cumbersome and would become intractable for bigger algorithms that are normally encountered in practice.
Asymptotic analysis
One observation that may help is that you want to worry about large input sizes only. If the input size is really small, how bad can a poorly designed algorithm get, right? Mathematicians have a tool for this sort of analysis called asymptotic notation. The asymptotic notation compares two functions; let’s say, and for large values of . This fits in nicely with your need for comparing algorithms for very large input sizes.
Big O notation
One of the asymptotic notations is the “Big O” notation. A function is considered , which is read as Big Oh of . If a positive real constant and an integer exists, such that the following inequality holds for all :
The following graph shows a plot of a function and that demonstrates this inequality.
Note that the above inequality does not have to hold for all . For , is allowed to exceed but for all values of beyond some value , is not allowed to exceed .
What good is this? It tells you that for large values of , will be within a constant factor of ...