【发布时间】:2013-04-10 13:42:14
【问题描述】:
我正在尝试使用以下序列创建 B+ 树,
10 20 30 40 50 60 70 80 90 100
所有索引节点应该有最少 2 个和最多 3 个键。我能够插入到 90,但是一旦插入 100,它就会将高度从 2 增加到 3。
问题是根的第二个孩子有一个节点,我无法修复它。它应该至少有2个,对吧?有人可以指导我吗?
更新:我正在遵循这个算法
If the bucket is not full (at most b - 1 entries after the insertion), add the record.
Otherwise, split the bucket.
Allocate new leaf and move half the bucket's elements to the new bucket.
Insert the new leaf's smallest key and address into the parent.
If the parent is full, split it too.
Add the middle key to the parent node.
Repeat until a parent is found that need not split.
If the root splits, create a new root which has one key and two pointers. (That is, the value that gets pushed to the new root gets removed from the original node)
P.S:我是手动进行的,以了解算法。没有代码!
【问题讨论】:
-
在没有看到任何代码的情况下指导您?我们不可能知道您的代码做错了什么。您是否怀疑问题可能是什么?
-
@usr- 没有代码,我是手工做的!这就是为什么没有语言标签,它的算法。
-
然后告诉我们你正在使用什么规则。
-
你的 B+ 树的顺序是什么
-
@RBarryYoung- 添加了更多细节..
标签: database algorithm indexing b-tree