4.5Algorithms & Data Structures

B-Trees & B+ Trees

Visualize how B-Trees maintain balance through splits and merges. Watch keys propagate upward during insertion and nodes consolidate during deletion, keeping the tree height-balanced for efficient disk-based access.

Order
Presets
B-Tree is empty. Insert a key to begin.
Order: 3Max keys: 2Min keys: 1
Tree is empty. Insert a key to begin.
Searching
Inserting
Split/Remove
Merge
Found
Promote
1.0x
Nodes0
Height0
Total Keys0
Splits0
Merges0
B-Tree Properties

Structure

  • -Every node has at most 2 keys
  • -Every non-root node has at least 1 keys
  • -All leaves are at the same depth

Split Operation

  • -When a node overflows (more than 2 keys)
  • -Median key is promoted to parent
  • -Node splits into two child nodes

Merge Operation

  • -When a node underflows (fewer than 1 keys)
  • -First tries to redistribute from a sibling
  • -If redistribution fails, merges with sibling
OperationAverageWorstDescription
SearchO(log n)O(log n)Binary search within each node
InsertO(log n)O(log n)May require splits up to root
DeleteO(log n)O(log n)May require merges or redistributions