← Back

B-Tree Simulator

What is a B-Tree?

A B-Tree is a balanced multiway search tree designed to keep its height small. Each node stores several sorted keys and can have several children. B-Trees are widely used in databases and file systems because one 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

This simulator uses the standard minimum-degree definition t. 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 key moves into the parent.

Borrowing and merging

Before deletion descends into a minimally filled child, it borrows from a sibling or merges with one so deletion remains valid.

B-Tree versus B+ Tree

This is a B-Tree: records may be represented by keys in internal or leaf nodes. A B+ Tree stores records in leaves and usually links its 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.