问题
Is 2^n = Θ(4^n)?
I'm pretty sure that 2^n is not in Ω(4^n) thus not in Θ(4^n), but my university tutor says it is. This confused me a lot and I couldn't find a clear answer per Google.
回答1:
2^n
is NOT big-theta (Θ) of 4^n
, this is because 2^n
is NOT big-omega (Ω) of 4^n
.
By definition, we have f(x) = Θ(g(x))
if and only if f(x) = O(g(x))
and f(x) = Ω(g(x))
.
Claim
2^n is not Ω(4^n)
Proof
Suppose 2^n = Ω(4^n)
, then by definition of big-omega there exists constants c > 0
and n0
such that:
2^n ≥ c * 4^n
for all n ≥ n0
By rearranging the inequality, we have:
(1/2)^n ≥ c
for all n ≥ n0
But notice that as n → ∞
, the left hand side of the inequality tends to 0
, whereas the right hand side equals c > 0
. Hence this inequality cannot hold for all n ≥ n0
, so we have a contradiction! Therefore our assumption at the beginning must be wrong, therefore 2^n is not Ω(4^n)
.
Update
As mentioned by Ordous, your tutor may refer to the complexity class EXPTIME, in that frame of reference, both 2^n
and 4^n
are in the same class. Also note that we have 2^n = 4^(Θ(n))
, which may also be what your tutor meant.
回答2:
Yes: one way to see this is to notice 4^n = 2^(2n)
. So 2^n
is the same complexity as 4^n
(exponential) because n
and 2n
are the same complexity (linear).
In conclusion, the bases don't affect the complexity here; it only matters that the exponents are of the same complexity.
Edit: this answer only shows that 4^n
and 2^n
are of the same complexity, not that 2^n
is big-Theta of 4^n
: you're correct that this is not the case as there is no constant k
such that k*n^2 >= n^4
for all n
. At some point, n^4
will overtake k*n^2
. (Acknowledgements to @chiwangc / @Ordous for highlighting the distinction in their answer/comment.)
回答3:
Yes. Both have exponential complexity.
来源:https://stackoverflow.com/questions/26119413/are-2n-and-4n-in-the-same-big-%ce%98-complexity-class