dubyaa
dubyaa

Reputation: 199

How to do B-Tree Insert

I am trying to insert 3 values into this B-Tree, 60, 61, and 62. I understand how to insert values when a node is full, and has an empty parent, but what if the parent is full?

For example, when I insert 60 and 61, that node will now be full. I can't extend the parent, or the parent of the parent (because they are full). So can I change the values of the parent? I have provided an image of the B-tree prior to my insert, and after.

Before insert of 60, 61, 62 Attempt to insert 60, 61, 62: After Notice I changed the 66 in the root to 62, and added 62 to to the <72 node. Is this the correct way to do this?

Upvotes: 1

Views: 1832

Answers (1)

Jerry Coffin
Jerry Coffin

Reputation: 490148

With the insertion you've done, you get what's normally referred to as a B* tree. In a "pure" B-tree, the insertion when the root is full would require splitting the current root into two nodes, and creating a new root node above them (B-tree implementations do not require that root node to follow the same rule as other nodes for the minimum number of descendants, so having only two would be allowed).

Upvotes: 3

Related Questions