O(n^2) vs O (n(logn)^2)

后端 未结 6 2135
悲哀的现实
悲哀的现实 2021-02-01 23:18

Is time complexity O(n^2) or O (n(logn)^2) better?

I know that when we simplify it, it becomes

O(n) vs O((logn)^2)
6条回答
  •  天涯浪人
    2021-02-01 23:23

    O(n^2) vs. O(n*log(n)^2)
    <=> O(n) vs. O(log(n)^2) (divide by n)
    <=> O(sqrt(n)) vs. O(log(n)) (square root)
    <=> polynomial vs. logarithmic
    

    Logarithmic wins.

提交回复
热议问题