Question

Say we have a B-Tree with the following structure:

           [5] [10]
          /   |    \
    [1][2]  [6][8]  [11][14]

Is it appropriate to say that 5 and 10 are the "keys" for the buckets at the bottom of the tree? Or am I totally missing the definition of "keys" for B-trees?

Was it helpful?

Solution

Generally, tree structures store a collection of values called keys. In the above tree, all the listed numbers are keys. He term keys is appropriate since trees often store key/value pairs and the balancing and lookup logic only applies to keys.

Hope this helps!

OTHER TIPS

Wikipedia says:

Each internal node of a B-tree will contain a number of keys. The keys act as separation values which divide its subtrees.

So, yes, that would be the definition of "keys" for B-trees.

I would prefer to say 5 and 10 are the "keys" of the root.

A b-tree node can be defined as below:

class Node {
    Integer[] keys;
    Node[] children;
    // constructor ...
}

So the root [5] [10] is a node with 3 children, containing keys 5 and 10.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top