I'm trying to order the following functions in terms of Big O complexity from low complexity to high complexity:
100n, 2^n , 2^log^3 n , log^n, n^100 , log log n, 2^n^2, n^log n , n^√n , 2^2^n
Here, all logs are base 2.
I have ordered them following way. Is this order of Big O-complexity correct?
log n
100n
log log n
2^n
n^100
n^√n
n^log n
2^log^3 n
2^n^2
2^2^n
CodePudding user response:
Correct order is:
log log n
log n
100n
n^100
n^log n
n^√n
2^log^3 n
2^n
2^n^2
2^2^n
When comparing any two functions,
- cancel out like terms.
- apply 'log' on both sides => as many times as possible
- substitute very large values for n => 2^100, 2^2^10 etc., (since logs are all base 2)