File tree Expand file tree Collapse file tree
docs/md/algorithm/data-structures Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,9 +39,11 @@ lock: need
3939</div >
4040
4141- 2-3 树的插入过程与 BST 树类似,会通过树的左右节点大小,找到自己的插入位置。
42- - 一个节点可以右1-3个元素 ,但当元素个数为3时,则需要调衡。把三个节点的中间节点晋升上来,其余两个节点为子节点。
42+ - 一个节点可以有1-2个元素(注意:不是1-3个) ,但当元素个数为3时,则需要调衡。把三个节点的中间节点晋升上来,其余两个节点为子节点。
4343- 如果进行一次调衡后,上一层父节点达到3个元素,则需要2次调衡,来满足2-3树的规则。
4444
45+ ** 注意** :2-3树的定义是每个节点可以有1-2个元素,当插入导致节点有3个元素时需要立即调衡。例如在插入节点9之前的树结构中,父节点6应该只有一个元素,其左子树为节点5。这样的结构符合2-3树的定义,也便于后续插入节点9时的调衡操作。
46+
4547** 咋样** ,是不看过这个图之后对于2-3树的实现已经有感觉了,想动手写写试试了?
4648- 源码地址:[ https://github.com/fuzhengwei/java-algorithms ] ( https://github.com/fuzhengwei/java-algorithms )
4749- 本章源码:[ https://github.com/fuzhengwei/java-algorithms/tree/main/data-structures/src/main/java/tree ] ( https://github.com/fuzhengwei/java-algorithms/tree/main/data-structures/src/main/java/tree )
You can’t perform that action at this time.
0 commit comments