-1

I'm trying to prove/disprove that (n^2 log n + 10) / (n - 10) = O(n log n)

I think it's wrong, since we can separate (n^2 log n)/(n-10) - 10/(n-10), and we can't simplify any further. There is no way to remove the 10s, which would make it n^2 log n / n which is O(n log n), but how do I "disprove it"?

Andrew Raleigh
  • 311
  • 3
  • 13
  • When you have a sum of terms, you only need to consider the fastest-growing term, so you can forget about the 10/(n-10) part. For the (n^2 log n)/(n-10) term, you should go to the formal definition of big-O, and look for appropriate constants x0 and M that satisfy the defining inequality for O(n log n), or show that they cannot exist. How close are 1/n and 1/(n-10) when n=100? n=1000? n=1000000? If you know n > 1000, can you find a multiplier that makes the inequality always true? – Jim Lewis Sep 21 '17 at 23:48

2 Answers2

3

To supplement @trentcl's answer, recall the definition of big-O:

enter image description here

... for some constant K.

Therefore, to prove this function is O(n log n), we need the following to be true:

enter image description here

And we find that:

enter image description here

Which is obviously positive if K > 1, thus proving that the function is indeed O(n log n).


As a side note, big-Omega states the opposite:

enter image description here

And setting K ≤ 1 from before satisfies this. Therefore the function is both O(n log n) and Ω(n log n), which means it is best described as ϴ(n log n).

meowgoesthedog
  • 14,670
  • 4
  • 27
  • 40
1

Big-O notation is about the limiting behavior of the function as n increases without bound. There are a lot of "shortcuts" you can take in finding the asymptotic complexity of a function that are not valid algebraic steps in that they do not result in a function with the same value (but merely the same asymptotic behavior).

For example, in (n^2 log n + 10)/(n - 10), imagine picking a very large value for n, like 2^100. If you pick a large enough value, n-10 will be virtually indistinguishable (in terms of sheer size) from n, right? And n^2 log n will definitely be big enough to dwarf that puny +10. So as n increases, the value of that function gets asymptotically closer to the value of (n^2 log n)/n which is just n log n.

So your belief

there is no way to remove the 10s

is false.

meowgoesthedog's answer shows how you can prove that f(n) is O(n log n) a little more formally. It's worth noting that the argument given in the paragraph above is not mathematically rigorous. Often, when you're trying to prove something, you have to make an intuitive leap to the answer, and then show that the assumption must be true with more formal means.

trent
  • 25,033
  • 7
  • 51
  • 90