Asymptotic Complexity of Logarithms and Powers

前端 未结 3 1710
抹茶落季
抹茶落季 2020-12-18 15:53

So, clearly, log(n) is O(n). But, what about (log(n))^2? What about sqrt(n) or log(n)--what bounds what?

There\'s a family of comparisons like this:
n^a versu

3条回答
  •  [愿得一人]
    2020-12-18 16:26

    log n -- O(log n)
    sqrt n -- O(sqrt n)
    n^2 -- O(n^2)
    (log n)^2 -- O((log n)^2)
    

    n^a versus (log(n))^b

    You need either bases or powers the same. So use your math to change n^a to log(n)^(whatever it gets to get this base) or (whatever it gets to get this power)^b. There is no general case

提交回复
热议问题