I should prove or disprove the equation
n^2 - 4n = Big-Theta(2^n)
As far as i know i need to prove the following two equations:
f = O(g)
g = O(f)
I started to solve f = O(g)
n^2 - 4n = c * 2^n // use log
2log(n) - log(4n) = log(c) * n * log(2)
2log(n) - (log(4) + log(n)) = log(c) * n //log(2) at base 2 is 1
But how do i continue from here on?
答案 0 :(得分:2)
You cannot prove that n^2-4n=Theta(2^n)
because the statement isn't true.
There are several equivalent ways to define the big-theta notation. One is in terms of big-Oh and big-Omega notations, i.e., that f=Theta(g)
if f=O(g)
and f=Omega(g)
. This means that there are constants C,D>0
such that for all sufficiently large n
we have C*g(n) <= f(n) <= D*g(n)
, that is we can "sandwich" the function f
between C*g
and D*g
. If this should be the case then the limit of f(n)/g(n)
as n
goes to infinity should be a constant---otherwise one of the functions grows asymptotically faster than the other and there's no way to sandwich the functions in that manner because one of the functions will eventually escape (it grows faster than constant times the other function).
To see that n^2-4n
is not Theta(2^n)
, it thus suffices to look at the following limit:
lim_{n -> infty} (n^2-4n)/2^n = 0
This means that the function 2^n
grows asymptotically faster than n^2-4n
, so there's no way to sandwich n^2-4n
between C*2^n
and D*2^n
for all sufficiently large n
for some C,D>0
.
答案 1 :(得分:0)
There is a difference between big-O and theta notation. In your question, you used both.
If using theta notation, by inspection, we can see that n^2 != 2^n, therefore false.
If using big-O notation, by inspection, we can see that n^2 < 2^n, therefore true.
As far as your formal proof, remember logarithmic properties, log(a - b) cannot be expanded to log(a) - log(b).