知识卡片
二叉树为何要平衡
二叉搜索树用一个键划分左右两组,左子树更小,右子树更大。插入顺序若反复延长一侧,查找路径就会接近链表,最坏走过全部节点。旋转把中间键提升成局部根,并有序重接两侧节点,可减少偏斜且保持遍历顺序,使高度维持在对数级。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 2. B-Tree Basics Chapter 2. B-Tree Basics · 查看原书依据
In the balanced tree, following the left or right node pointer reduces the search space in half on average, so lookup complexity is logarithmic: O(log2 N).
参考来源
- 位置:《Database Internals》Chapter 2. B-Tree Basics(book-source:extracted/Database Internals A deep-dive into how distributed data systems work (Alex Petrov)/_epub-src/OEBPS/ch02.html#idm46104533625848,段 18)
- 结论依据:原文对照平衡与退化的搜索复杂度,并以旋转枢轴解释不改键序的局部调整。
- 原始内容:In the balanced tree, following the left or right node pointer reduces the search space in half on average, so lookup complexity is logarithmic: O(log2 N).