-2

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))?

2 Answers2

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