Misc Complexity Tricks
Tags | CS161ComplexityExamples |
---|
Some important things
If is and it is not , then it is also the case that .
If and it is not , then . This is because grows faster than (and not just by a constant, which can mess things up).
And more generally, this holds for any monotonically increasing function composed with .
However, the difficulty comes when . When this is the case, you can’t say anything about the relationship between and . It all depends on the constant factor between .
In general, when you see if something satisfies a certain complexity, you should look for counterexamples. For , find cases in which we go above, and for , find cases in which we go below.
Chaining bounds
Say that you wanted to prove that . You could do the directly, but sometimes that’s hard. Sometimes, you can prove that , and then you can prove that . Implicitly, this proves that .
You can do this same trick with but the other way around. You can show that and .
The “distillation” idea
When talking about big O, theta, or omega notation, it’s often accurate to just consider the largest term. So will be equivalent to , etc. However, this breaks down for a few key things
Variable substiution
Sometimes it’s easier to compare when you substitute variables. For example, when proving that , we log both sides and let , where it becomes obvious that
Ratio test
If you’re not sure which one grows quicker, take the ratio and then take the limit as . This is known as the ratio test
in sequences, and it does work. If the ratio tends to zero, then we say that (yes, it’s lowercase o)
Floors and ceilings
The best bet is to look at the best case and worst case with floors and ceilings when the floor/ceiling gets used vs when it doesn’t get used and you just pass through whatever is on the inside.
Exponents
In general, and have different asymptotic behavior. Formally, this is because if you take the log of both sides in your derivation of , you might get
The is no longer a slope, but rather an intercept. Therefore, if , then our inequality is satisfied. Otherwise, it is contradicted.
One identity to note:
![](Misc%20Complexity%20Tricks%209671f840801347eaa58624eeba4105d4/Untitled.png)
Binomials
Remember that
and that
Logs
We can derive from the ratio test that for any constants . This means that the polylogarism
grows slower than any polynomial function
Interesting example with vs
We can show that these two are actually related by . First, we show that . This is trivial, because . As such, we conclude that
Next, we unroll the summation and we get that . Therefore, . This means that , which means that .
Finally, taken together, this means that . This is a really nice trick!
Factorial
A weak upper bound is , but this isn’t fun. We can use Stirling’s approximation
, which states that
which means that with large enough , we can disregard the additional term.
From Sterling’s approximation, we get that , which is very interesting.