Why is 2n^2 = O(n^3) ?
This is given as an example of big O notation in the MIT OCW Introduction to Algorithms (SMA 5503) course. It's in lecture 2
Specifically, it looks to me like that should be O(n^2) --I thought that's what dropping the leading terms means.
It is O(n^2)
hmm. Then the professor must've made a mistake. Thanks!
Well
Recall that big 0 is an upper bound
So technically everything that's O(n) is also O(n^2) and all higher values?
Yeah, but we'd like to have as tight a bounds as possible
I'm watching the vid to see if I can figure out why he was using that
yeah he just made a mistake.
yeah, I was really confused. It seems like the point of big O notation is to try to describe the growth of functions for arbitrarily large inputs, but calling that O(n^3) only seems to describe the function's behavior for n = 2.
Because the definition is: \[f\in O(g(x)) \iff \exists C,k \text{ such that }|f(x)| \le C|g(x)|, \forall x >k \]
In this case \(f(x) = 2n^2, g(x) = n^2\) And my C would be 2 and my k would be 0
Actually any x value can serve as the k witness.
Ack. that's terrible notation, sorry.
Should be f(n) and g(n) not f(x) etc.
Cool. Thanks!
Join our real-time social learning platform and learn together with your friends!