如何进行 B 树插入
我正在尝试向此 B 树插入 3 个值:60、61 和 62。我了解如何在节点已满并且父节点为空时插入值,但是如果父节点已满怎么办?
例如,当我插入 60 和 61 时,该节点现在将已满。我无法扩展父级或父级的父级(因为它们已满)。那么我可以改变父母的价值观吗?我在插入之前和之后提供了 B 树的图像。
尝试插入 60, 61, 62: 请注意,我将根中的 66 更改为 62,并将 62 添加到 <72 节点。这是执行此操作的正确方法吗?
I am trying to insert 3 values into this B-Tree, 60, 61, and 62. I understand how to insert values when a node is full, and has an empty parent, but what if the parent is full?
For example, when I insert 60 and 61, that node will now be full. I can't extend the parent, or the parent of the parent (because they are full). So can I change the values of the parent? I have provided an image of the B-tree prior to my insert, and after.
Attempt to insert 60, 61, 62:
Notice I changed the 66 in the root to 62, and added 62 to to the <72 node. Is this the correct way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
完成插入后,您将得到通常所说的 B* 树。在“纯”B 树中,当根已满时插入需要将当前根拆分为两个节点,并在它们之上创建一个新的根节点(B 树实现不要求根节点遵循相同的规则)与其他节点一样,后代数量最少,因此只允许有两个)。
With the insertion you've done, you get what's normally referred to as a B* tree. In a "pure" B-tree, the insertion when the root is full would require splitting the current root into two nodes, and creating a new root node above them (B-tree implementations do not require that root node to follow the same rule as other nodes for the minimum number of descendants, so having only two would be allowed).