我正在尝试使用以下序列创建 B+ 树,
10 20 30 40 50 60 70 80 90 100
所有索引节点应该有最少 2 个和最多 3 个键。我能够插入到 90,但是一旦插入 100,它就会将高度从 2 增加到 3。
问题是 root 的第二个孩子有一个节点,我无法修复它。它应该至少有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)
PS:我正在手动进行,以了解算法。没有代码!