I’ve just been introduced to Big-O notation and I’ve been given some questions. However I’m confused as to how to determine the value of n0.
I have to show that 3n^3 +20n^2 + 5 is O(n^3). So far I have:
3n^3 + 20n^2 + 5 <= cn^3
(3 - c)n^3 + 20n^2 + 5 <= 0
5 <= n^3(c - 3) - 20n^2
5 <= n^2(n(c - 3) - 20)
I just don’t know what to do from here to find n0 and c. Would someone mind explaining?
Depending on where you want the greater than condition to begin, you can now choose n0 and find the value.
For example, for n0 = 1:
It’s worth noting that by the definition of Big-O notation, it’s not required that the bound actually be this tight. Since this is a simple function, you could just guess-and-check it (for example, pick 100 for c and note that the condition is indeed true asymptotically).
For example:
That inequality holding true is enough to prove that f(n) is O(n^3).
To offer a better proof, it actually needs to be shown that two constants,
candn0exist such thatf(n) <= cg(n) for all n > n0.Using our c = 28, this is very easy to do:
(That’s a pretty badly done ‘proof’ but hopefully the idea shows.)