gpt4 book ai didi

algorithm - 无法理解算法 P146 中最坏时间复杂度的证明

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:28:10 27 4
gpt4 key购买 nike

Algorithms Fourth Edition第146页给出了quick-union算法最差时间复杂度的证明。它说

Let's assume the height of a tree which has i nodes has the maximum height of log(i).

Given i + j = k, i <= j, when the tree of i and j nodes are unioned, the height of the tree = 1 + log(i) = log(i + i) <= log(i + j) = log(k).

我不明白为什么 1 + log(i) = log(i + i)

最佳答案

因为 log(i + i) = log(2i) = log(2) + log(i) 并且 log(2) = 1,我们可以说 log(i + i) = 1 + log(i)

关于algorithm - 无法理解算法 P146 中最坏时间复杂度的证明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51453342/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com