mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-24 05:14:06 -06:00
626 B
626 B
| title | tags |
|---|---|
| big-o | cosc201 |
big-o
Big O means
f(n) = O(g(n))if there is some constantA > 0such that for all sufficiently large n,f(n) ≤ A × g(n).
- Big O provides upper bounds only. (usually on worst case runtimes)
- sometimes cost will be much less
- does not take special cases into account
- upper bound
- sometimes cost will be much less
Osays thatg(n)provides an upper bound forf(n)- "Insertion sort is $O(n^2)$" -> the maximum number of basic operations in never more than some constanct times
n^2
- "Insertion sort is $O(n^2)$" -> the maximum number of basic operations in never more than some constanct times
- if
f(n) =O(g(n))then the opposite is also true - usually
f(n)is complex butg(n)is very simple