Reputation: 21
For a function like f(n) = 20n^2 + 5n + 7
, the Θ-notation clearly is Θ(n^2)
.
But what about a more complex function where we have (n^3.2)^-n
in the denominator?
f(n) = (n^2 + 2)/(1 + (n^3.2)^-n)
[![f(n) = (n^2 + 2)/(1 + (n^3.2)^-n)][1]][1]
Kindly explain the solution for better understanding.
Upvotes: 1
Views: 136
Reputation: 25943
Yes, it is Θ(n²)
as well.
f in Θ(g)
is defined as f in O(g)
and f in Ω(g)
at the same time.
See the definition from Wikipedia:
Your method f
is
while g
is just g(n) = n²
.
Now, informally, the denominator in f
goes against 1
(1 + 0
) since the -n
grows extremely fast when going n ➝ ∞
.
O(n²)
But step by step. Let us first deal with the simple direction, showing that f in O(n²)
.
You have to show that there is a constant factor k
and a special starting value n₀
from which on, all n > n₀
will yield a smaller value. So that
f(n) ≤ k · g(n)
i.e.
Now, that is quite simple since you can just estimate using ≤
. The denominator is always positive and always greater 1
since the right part of the addition is always positive. Hence, it holds that you can just leave it away without making it bigger:
and that is definitely smaller than k · n²
if we set maybe k = 10
, n₀ = 10
.
Ω(n²)
The other direction is more tricky since now we have to show that f
is actually bigger than k · n²
despite the denominator making it smaller.
However, the tricky part in the denominator (n^3.2)^-n
grows very fast against 0
, informally because the -n
is much stronger than n^3.2
. Take a look at this plot:
You can easily show that this is monotonically decreasing and going against 0
, after the maxima at around n ≈ 0.36
. So we can just take a higher value, such as n₀ = 10
and then we have the denominator under good control.
Now we can start the estimation with an upper bound:
So, we pick k = 1/11
, n₀ = 10
and are done.
Θ(n²)
Since we just showed that f in O(n²)
and f in Ω(n²)
, it follows that f in Θ(n²)
.
Upvotes: 1
Reputation: 76
It should be still O(n^2), right?
3.2^(-n) is getting infinitely close to 0 when n is increased. Then, the denominator is approximately 2 (= 1 + n^0).
Upvotes: 1