Example-3 Find upper bound for f(n) = n^4 + 100n^2 + 50
Solution: n^4 + 100n^2 + 50 ≤ 2n^4, for all n ≥ 11 ∴ n^4 + 100n^2 + 50 = O(n^4 ) with c = 2 and n0 = 11
In the above question the solution says n>11 and n-nought is 11. can anybody explain why is it 11? for reference - this is a problem from the Data Structures and Algorithms Made Easy by Narasimha Karumanchi
It doesn't say that n>11
it says that n4 + 100n2 + 50 ≤ 2n4
, for all n ≥ 11
.
Is it true? You can substitute n
for 11
in the formula and check it yourself.
How was 11
obtained? By solving the inequality.
It is not finding an upper bound for a function. It is an asymptotic analysis of a function with big-O notation. Hence, the constant c = 11
does not matter for the analysis, and if you can show the inequality is valid for all n
greater than any constant, for instance c = 100
, that will be accepted. By the way, you can show that it is true for all n > 11
by the mathematical induction.
f(n) = n^4 + 100n^2 + 50
Intuitively, n^4
grows very fast; n^2
grows less fast than n^4
; and 50
doesn't grow at all.
However, for small values of n
, n^4 < 50
; additionally, the n^2
term has a factor 100 in front of it. Because of this factor, for small values of n
, n^4 < 100 n^2.
But because we have the intuition that n^4
grows much faster than n^2
, we expect that, for n big enough, 100 n^2 + 50 < n^4
.
In order to assert and prove this claim, we need to be more precise on what "for n big enough" means. Your textbook found an exact value; and they claimed: for n ≥ 11, 100 n^2 + 50 < n^4
.
How did they find that? Maybe they solved the inequality for n
. Or maybe they just intuited it by noticing that:
100 n^2 = 10 * 10 * n * n`
n^4 = n * n * n * n
Thus n^4
is going to be the bigger of the two as soon as n is bigger than 10.
In conclusion: as soon as n ≥ 11, f(n) < 2 n^4
. Thus, f(n) satisfies the textbook definition for f(n) = O(n^4)
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.