时间复杂度O((log(N))^ 2)是否等于O(sqrt(N))?

时间:2020-07-30 17:02:47

标签: math time-complexity complexity-theory

我在lowest common ancestor problem中看到了以下等效项:
1
但我不明白为什么,所以我想弄清楚如何证明:
enter image description here

1 个答案:

答案 0 :(得分:1)

如@Joni所述,您可以证明if (member.roles.cache.has(RolesArray[i])){ 给出了预期的big-O表示法。

但是您可能会感到麻烦,因为此等号是"one way" one

log(N)^2 < 16 * sqrt(N)是正确的,但是 O(log(N)^2) = O(sqrt(N))是错误的!