问题
List the following functions in non-descending order of asymptotic growth rate. If two or more functions have the same asymptotic growth rate then group them together.
g1(n) = n
g2(n) = n^3 +4n
g3(n) = 2n log(base 2) n
g4(n) = 2^n
g5(n) = 3 ^ (3 * log(base 3) n)
g6(n) = 10^n
I've been looking through several examples online but I have no idea how to do this, it just seems like a completely foreign concept to me. If anyone could help me, that would be much appreciated. how do I even calculate the growth rate?
回答1:
Many of the techniques that you might find most useful here are tricks for manipulating expressions involving logs and exponents.
First, you might want to review the power rule for logarithms:
a logb c = logb ca.
Next, there's the fact that exponents and logarithms are inverses of one another:
logb bn = blogb n = n
These rules might help you rewrite g5(n), for example.
Here's another helpful rule:
(ab)c = abc = (ac)b.
You can actually use the two previous rules to change the bases of exponential functions. For example, suppose you want to compare 2n to 5n. Notice that
5n = (2log2 5)n
= (2n)log2 5.
Does that make it easier to see which of these two functions will grow more rapidly?
Finally, you might want to use the following fact: all polynomials grow slower than all exponents whose base is greater than 1. This means that nk grows strictly slower than an for any n > 1. Similarly, all polynomials grow strictly faster than all logarithms, so logb n < nk for all k > 0.
Using the above rules, see if you can try to rewrite each of these expressions as either a logarithm of n, a polynomial in n, or something exponential in n. From there, you can then rank the logarithmic expressions against themselves, the polynomials against themselves, and the exponentials against themselves, then write them out in order.
Generally speaking, the techniques mentioned here are super useful going forward. I hope that this gets you on the right track!
回答2:
There's a very simple rule that can help out with these problems. It's very easy to prove using the basic definitions of calculus and complexity (and it might be a good exercise to boot).
Given two functions, f(n) and g(n):
if limn → ∞f(n) / g(n) = 0, then f(n) = o(g(n).
if limn → ∞f(n) / g(n) = ∞, then f(n) = w(g(n) (this follows from the previous point).
if limn → ∞f(n) / g(n) = c, 0 < c < ∞, then f(n) = Θ(g(n).
Looking at your examples here, they can each and every one of which be solved using these. E.g., limn → ∞ g1(n) / g2(n) = 0, so g1(n) = o(g2(n)).
来源:https://stackoverflow.com/questions/35003269/ordering-functions-by-asymptotic-growth-rate