I have looked at every example of a B+tree in JavaScript on GitHub, and have tried simplifying one down to semi-readable code from this. But I still don't understand what the structure of the keys
array is for each internal node. What do the keys look like? How do you use them in the get/insert/remove algorithms? Specifically for this question, I want to treat the B+tree as an array from the outside, or a list of sorts. So I want the "key" to be an integer (the index of the item in the array). How do I do this? What is an example JSON demo showing what a simple B+tree will look like in this case?
{
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' }
}
]
}
]
}
What do the keys do even? I get they are used for lookup, somehow, but how?
Say there are 32 internal nodes from the base, and each of those have 32 internal nodes, and each of those have a bunch of leaves. What are the keys in the internal nodes?
I want to implement a robust B+tree in JavaScript, and am having a hard time understanding the basics of the B+tree at this moment.