The process of determining how efficient the algorithm is. Complexity analysis involves both Time and Space Complexities of an Algorithm.
It's needed to determine the better algorithm for the purpose.
It is classified into 3 types.
- Best Case - Big Omega
- Medium Case - Big Theta
- Worst Case - Big O
In Maths log means log10, in Computer science log2.
-
log2 16 = ?; 24 = 16; log2
16 = 4
; -
log2
8 = ?
; 23 = 8; log28 = 3;
-
log2
12 =?
; 23 = 8; 24 = 16; log212 = 3.5
Very Important concept to understand before going deep inside Time and Space complexity.
- Constant: O(1)
- Logarithmic: O(log(n))
- Linear: O(n)
- Log-Linear: O(nlog(n))
- Quadratic: O(n2)
- Cubic: O(n3)
- Exponential: O(2n)
- Factorial: O(n!)