34C. Comparisons of Common Functions

Here is a comparison of some common functions of n in terms of how fast they grow as n gets large. The list is in order from slowly growing functions to rapidly growing functions. If f(n) occurs earlier in the list than g(n) then f(n) is O(g(n)) but g(n) is not O(f(n)). For example, n2 is O(n3), but n3 is not O(n2).

log2(n)
(log2(n))2
n
n
n log2(n)
n2
n3
1.01n
2n

Exercises

  1. True or false: n is O(log2(n)). Answer

  2. True or false: nlog2(n) is O(n2). Answer

  3. True or false: n2 is O(nlog2(n)). Answer

  4. True or false: n2 is O(1.1n) Answer