We, as computer scientists, care about the efficiency of the programs we write. This is true especially for when we care about how the program scales with the size of the input. One of the ways we can define the efficiency of a program is by measuring its running time. The running time is defined as the number of steps executed and it is defined this way so that the efficiency of the algorithm is independent of hardware. So basically, we want to know how our running time increases as the size of our input increases.
O(n) notation acts as an upper bound to the running time of the algorithm and, it is used to classify functions depending on how they scale. Some of the most common ones from slowest to fastest growth rate:
1) f(n) = 1
2) f(n) = log n
3) f(n) = sqrt(n)
4) f(n) = n
5) f(n) = n^2
6) f(n) = 2^n
7) f(n) = n^n
As an example, a more rigorous definition of O(n^2) = $$ \exists c \in R+, \exists B \in N, \forall n \in N, n >= B => f(n) < cn^2 $$
O(n) notation acts as an upper bound to the running time of the algorithm and, it is used to classify functions depending on how they scale. Some of the most common ones from slowest to fastest growth rate:
1) f(n) = 1
2) f(n) = log n
3) f(n) = sqrt(n)
4) f(n) = n
5) f(n) = n^2
6) f(n) = 2^n
7) f(n) = n^n
As an example, a more rigorous definition of O(n^2) = $$ \exists c \in R+, \exists B \in N, \forall n \in N, n >= B => f(n) < cn^2 $$