【发布时间】:2021-01-07 06:28:55
【问题描述】:
我查看了 GitHub 上 JavaScript 中 B+tree 的每个示例,并尝试了 this 中的 simplifying one down to semi-readable code。但是我还是不明白每个内部节点的keys数组的结构是什么。钥匙长什么样?您如何在 get/insert/remove 算法中使用它们?特别是对于这个问题,我想将 B+tree 视为外部数组或排序列表。所以我希望“键”是一个整数(数组中项目的索引)。我该怎么做呢?什么是 JSON 演示示例,展示了在这种情况下简单 B+树的外观?
{
type: 'tree',
keys: [?],
children: [
{
type: 'internal',
keys: [?],
children: [
{
type: 'leaf',
value: { foo: '123' }
},
{
type: 'leaf',
value: { foo: '234' }
}
]
},
{
type: 'internal',
keys: [?],
children: [
{
type: 'leaf',
value: { foo: '345' }
},
{
type: 'leaf',
value: { foo: '456' }
}
]
}
]
}
键的作用是什么?我知道它们用于查找,不知何故,但是如何?
假设基础有 32 个内部节点,每个内部节点都有 32 个内部节点,每个内部节点都有一堆叶子。内部节点的key是什么?
我想在 JavaScript 中实现一个健壮的 B+树,目前很难理解 B+树的基础知识。
【问题讨论】:
标签: algorithm data-structures b-tree b-plus-tree