Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
B-tree
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Insertion and deletion=== To maintain the predefined range of child nodes, internal nodes may be joined or split. Usually, the number of keys is chosen to vary between {{mvar|d}} and <math>2d</math>, where {{mvar|d}} is the minimum number of keys, and <math>d+1</math> is the minimum [[Outdegree#Indegree and outdegree|degree]] or [[branching factor]] of the tree. The factor of 2 will guarantee that nodes can be split or combined. If an internal node has <math>2d</math> keys, then adding a key to that node can be accomplished by splitting the hypothetical <math>2d+1</math> key node into two {{mvar|d}} key nodes and moving the key that would have been in the middle to the parent node. Each split node has the required minimum number of keys. Similarly, if an internal node and its neighbor each have {{mvar|d}} keys, then a key may be deleted from the internal node by combining it with its neighbor. Deleting the key would make the internal node have <math>d-1</math> keys; joining the neighbor would add {{mvar|d}} keys plus one more key brought down from the neighbor's parent. The result is an entirely full node of <math>2d</math> keys. A B-tree is kept balanced after insertion by splitting a would-be overfilled node, of <math>2d+1</math> keys, into two {{mvar|d}}-key siblings and inserting the mid-value key into the parent. Depth only increases when the root is split, maintaining balance. Similarly, a B-tree is kept balanced after deletion by merging or redistributing keys among siblings to maintain the {{mvar|d}}-key minimum for non-root nodes. A merger reduces the number of keys in the parent potentially forcing it to merge or redistribute keys with its siblings, and so on. The only change in depth occurs when the root has two children, of {{mvar|d}} and (transitionally) <math>d-1</math> keys, in which case the two siblings and parent are merged, reducing the depth by one. This depth will increase slowly as elements are added to the tree, but an increase in the overall depth is infrequent, and results in all leaf nodes being one more node farther away from the root.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)