B-Tree Simulator

A B-Tree is a balanced multiway search tree designed to keep its height small. Each node stores several sorted keys and may have several children. B-Trees are widely used in databases and file systems because a single node can correspond to one storage page.

SearchO(log n)
InsertO(log n)
DeleteO(log n)
All leavesSame depth

Tree operations

400 ms
B-Tree visualizationInteractive balanced multiway search tree.

Example B-Tree loaded. Choose an operation.

Keys0
Nodes0
Height0
Structural changes0

Search path

—

Sorted traversal

—

Node capacity for minimum degree t

non-root node:
  minimum keys = t - 1
  maximum keys = 2t - 1
  maximum children = 2t

before descending into a full child:
  split the child
  move its median key to the parent

B-Tree concepts

Minimum degree

A non-root node contains between t − 1 and 2t − 1 keys.

Splitting

Insertion never descends into a full child. The child is split first and its median moves into the parent.

Borrowing and merging

Deletion repairs minimally filled children by borrowing from siblings or merging nodes before descending.

B-Tree versus B+ Tree

A B-Tree may store records in internal or leaf nodes; a B+ Tree keeps records in leaves and usually links those leaves.

B-Tree invariants

InvariantMeaning
Sorted keysKeys inside every node remain in increasing order.
Child rangesEach child contains only keys in the range defined by adjacent parent keys.
OccupancyExcept for the root, every node has at least t − 1 keys.
BalanceEvery leaf appears at the same depth.