algorithmtime-complexitybig-ocomplexity-theory

Time Complexities n(log(n)) and log(n^n)


I was studying Time Complexities in my DSA lecture when this doubt popped in my mind. So firstly, is O(nlog(n)) = O(log(n^n))?

If yes, what type of Time Complexity does the O(log(n^n)) belong to? Is it Logarithmic/Quadratic/Exponential?

I tried browsing the other stackoverflow articles followed by Chatgpt and Gemini. Stackoverflow probably doesn't have this question and the AI models gave very distinct answers. Expecting human intelligence to give the answer.


Solution

  • No, O(log⁡(n)) is not the same as O(log⁡(n^n)). This is because log⁡(n^n) simplifies to n.log⁡(n), and n.log⁡(n) belongs to a different class of time complexity than log⁡(n).

    O(log⁡(n^n)), which is equivalent to O(n.log⁡(n)), is known as linearithmic time. This is a special case of quasilinear time, also referred to as log-linear time. You can read more about it here: Quasilinear time - Wikipedia.