Classes of Algorithms
f(n) | Name | Example |
1 | Constant | + |
log(n) | Logarithmic | binary search |
log2(n) | Log-squared | |
n | Linear | max of array |
n*log(n) | Linearithmic | quicksort |
n2 | Quadratic | selection sort |
n3 | Cubic | matrix multiply |
nk | Polynomial | |
2n | Exponential | knapsack problem |
When we use log(n), we often mean log2(n); however, the base of the log(n) does not matter: logk(n) = log(n) / log(k) Thus, a log(n) is converted to another base by multiplying by a constant; but we eliminate constants when determining Big O.