Click to See Complete Forum and Search --> : Help with understanding big 0 notation


miker158
December 8th, 2006, 02:48 PM
Hi, I have just started a module in data structures and have come accross these examples which don't make much sense to me.

1st.
5n^2 + 3nlogn + 2n + 5 is O(n^2)
5n^2 + 3nlogn + 2n + 5<= (5+3+2+5)n^2 = cn^2, for c =15. when
n>=n0 (note that n log n is zero for n =1).

2nd.
20n^3 + 10nlogn + 5 is O(n^3)
20n^3 + 10nlogn + 5<=35n^3, for n>=1

Now if I am understanding the 1st example correctly to find n0 n has to be 2 due to nlogn being zero n = 1, but i dont understand why n0 is 1 for the 2nd example if nlogn is zero for n =1. If anyone can give me a hint or a suggestion it would be great.

TheCPUWizard
December 8th, 2006, 03:05 PM
"The Big O" (at least here at codeguru) is used to meagure the Order of magnitude of a given task (in time, space or some other domain).

Consider simple geometry

the circumfrence of a circle of O(n). The circumfrence of a circle increases in a linear relationship to the radius.

the areas of a circle is O(n^2). The artea of a circle increases at a rate relative to the square of the radius.

Using a different analogy. Consider guessing a number, given some upper and lower known limits. If you guess the middle number, and are told higher/lower, or correct. Then you can use binary division to narrow down the number. In this case the situation involves O(log2(n)).

Does this help????

miker158
December 8th, 2006, 03:19 PM
Yes i can see that 5n^2 + 3nlogn + 2n + 5 is O(n^2) as the rate of change in magnitude is relative to 5n^2 . Which makes a lot of sense, i think my lack of understanding is in the justification f(n)<=cg(n), for n>= n0