algorithm - 为什么我们要努力保持树木平衡

标签 algorithm tree

我看到很多问题都在谈论平衡树。

例如,R-Tree 优于 KD-Tree,因为它们是平衡的。

与非平衡树相比,使用平衡树有什么优势?

最佳答案

搜索这棵树

O
 \
  O
   \
    O
     \
      O
       \
        O
         \
          O
           \
            O

将花费 Θ(N) 时间。搜索这棵树

     O
   /   \
  O     O
 / \   / \
O   O O   O

将花费 Θ(logN) 时间。由于搜索时间与树的高度成正比。

关于algorithm - 为什么我们要努力保持树木平衡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17264065/

相关文章:

algorithm - 如何在新算法中添加 weka 特征?

algorithm - 在 Haskell 中内存最有效的方法是什么?

java - 丰富 :tree -- unable to generate leaves dynamically?

rust - 了解 rust `Rc<RefCell<_>>`

c - 查找数组中重复数字的算法---Fastest Way

algorithm - 如何在 Matlab 中加速我的代码 [包括示例]?

javascript - 响应浏览器的最大 json 大小

javascript - 检查树是否展开或打开(Selenium/Python)

php - 使用一次性循环将平面数组转换为树

algorithm - 找出液体到达第 n 个杯子所需的时间