Interactive · 4 questions
Big O, , and are ways to measure how a function grows asymptotically as gets large. Let's start with big O, since the other two are very easy to learn after mastering big O.
Definition. A function is if there exists a constant such that holds for all sufficiently large .
Essentially, this means that if is asymptotically bounded above by (up to a constant factor).
Determine whether the function is .
Determine whether the function is .
Determine whether the function is .
Essentially, for any function , returns a class of functions which in a loose sense increase at most as quickly as the function as approaches infinity. This is the main intuition behind the somewhat-tricky definition given at the beginning of the article. It doesn't matter how the two functions compare for small - we only care about large .
We have analogous notation for dealing with functions which in a loose sense increase at least as quickly.
Definition. A function is if there exists a constant such that holds for all sufficiently large .
In other words, if is bounded below asymptotically by .
Select all the functions below such that .
Problem. Prove that if and only if .
Proof. If , then for some , for all sufficiently large . Therefore, for all sufficiently large , which means is asymptotically greater than a constant factor times , where the constant factor is taken to be . Thus, .
Conversely, if , then , so . So is bounded above by a constant multiple of , so .
Definition. A function is if it is both and .
In other words, if they grow at nearly the same rates as gets large.
Why is this under the CS topic? What does all this math stuff have to do with CS?
This is a very essential topic in CS and algorithm analysis. One of the first things we can ask about how good an algorithm is how it behaves as the size of the input changes. If an algorithm runs in (where is the input size), then we can double the input size and expect the computation time to increase linearly. If an algorithm runs in , then you can rest assured at night that it's faster than an algorithm that runs in .
For example, the P vs. NP problem asks if all problems that can be verified in polynomial time can be solved in polynomial time.