algorithm - A particular problem with btree insertion -


I'm playing with a very cool Beatri applet. I have a problem understanding a particular behavior. Take a look at this initial situation:

This particular sequence was included in the following: 10, 15, 30, 16, 70, 1, 9, 27, 45, 50, 55

My question is, [45] What happens to the node when I insert the next value in the sequence, 65.

[55,70] The node will be divided by 65, and at the median value, 65 will travel back [30,50] Will also divide the node my question Is that [45], why did node eliminate a child of [30,] node? The origin of the root has 3 children, the left most and the newest nodes have become the most different. 45 was among those values ​​and it seems that it could end up immediately [65,] node ... why?

A picture is worth a thousand words; The animation is equal to one lakh:

The thing worth noting here is that when the center node is drawn 50, then he has to throw his right child because it is very Is far down However, 65 needs a new left child, so 50 hands from 45 to 65 50 now needs a new right baby, and 65 in the node is needed, so it takes its place in newly formed 65.

The B-tree entry rule (where maximum node size is 4 items, 5 hair nodes) is illustrated here:

xr won 'is present and does not matter if you put it in a leaf (which you do earlier). However, if you have to split a node in half, then the new x is the center item that you have removed, and the new xr correct kid of x Is .


Comments