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.
Difference between Big O and Big Ω The difference between Big O notation and Big Ω notation is that Big O is used to describe the worst case running time for an algorithm. But, Big Ω notation, on the other hand, is used to describe the best case running time for a given algorithm.
Big-O is an upper bound. Big-Theta is a tight bound, i.e. upper and lower bound. When people only worry about what's the worst that can happen, big-O is sufficient; i.e. it says that "it can't get much worse than this".
This is what is meant by theta notation c(n) = Θ(n) . Note that c(n)/n² is also bounded, so c(n) = O(n²) as well — big-O notation is merely an upper bound on the complexity, so any O(n) function is also O(n²) , O(n³) ... However, since n²/c(n) = n is not bounded, then c(n) ≠ Θ(n²) .
Theta Notation (Θ-notation) Since it represents the upper and the lower bound of the running time of an algorithm, it is used for analyzing the average-case complexity of an algorithm.
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))
.
2^n is not Ω(4^n)
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)
.
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.
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.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With