Is it O(n^2 log n)? Can you show how it is derived? Is O(n^2 log n) the same as O((n^2) * (log n))?
Asked
Active
Viewed 78 times
-2
-
Actually it is O((n^2) * (log n))... – Mukit09 Sep 22 '15 at 07:10
-
3Is this a homrwork? Basic math and wikipedia are enough to answer in 3 minutes. – Ondrej Tucny Sep 22 '15 at 07:11
-
1Guys, power takes preceence over multiplication... parentheses are redundant. – Ondrej Tucny Sep 22 '15 at 07:12
2 Answers
3
Rigorous derivation:
By definition
T(n) = O(n Log(n)) <=> for some N and C, n > N => T(n) < C.n.log(n).
Then obviously
for these N and C, n > N => n.T(n) < C.n².log(n)
which implies
n.T(n) = O(n²log(n)).
0
Doing something n
times takes O(n)
time. And n log n
is just another way of writing n * log n
So we get:
O(n) * O(n * log n)
= O((n) * (n * log n))
= O(n * n * log n)
= O(n^2 * log n)
Yes, the two ways of writing it that you have shown are the same. This is, however, something completely different: O(n^(2 log n))

Emil Vikström
- 90,431
- 16
- 141
- 175