KickSolve • Free • Private

B-Tree Visualizer

A self-balancing search tree in which a node can contain multiple keys and have multiple children. Insert, delete and search, and see every rotation, recoloring, split and merge explained step by step.

Choose the order 3 to 6Splits and merges explainedKeys per node shown

How to use the B-Tree Visualizer on KickSolve

Three quick steps, no account needed.

Pick an orderChoose the order (maximum children per node). Order 4 means at most 3 keys per node.
Insert a valueThe log shows which child is followed at each node. If a node gets too many keys it splits and the median key moves up.
Delete a valueIf a node falls below the minimum, the log tries borrowing from a sibling first, and merges if neither sibling can spare a key.

About the B-Tree Visualizer on KickSolve

What it is and how it works.

What is a B-tree?

A B-tree is a self-balancing search tree where each node stores several sorted keys and has one more child than it has keys. Because nodes are wide, the tree is very shallow, which suits disks and databases.

Key properties (order m)

  • Each node has at most m children and m-1 keys
  • Every non-root node has at least ceil(m/2) children
  • All leaves are on the same level
  • Keys inside a node are sorted
  • Search, insert and delete are O(log n)

Real-world uses

  • Database indexes
  • File systems (NTFS, ext4 directories, HFS+)
  • Anywhere data is read in large blocks from disk

Comparing trees? Try the AVL Tree, Red-Black Tree, B-Tree or B+ Tree visualizer.

B-Tree cases at a glance

The situations the step-by-step log will name for you.

EventConditionWhat happens
InsertNode has more than m-1 keysSplit in half; the median key moves up to the parent
Delete from leafNode keeps at least the minimum keysJust remove the key
Delete from internal nodeKey is in an internal nodeReplace with its predecessor from a leaf, then delete there
UnderflowNode has too few keysBorrow through the parent from a sibling, or merge with a sibling
Root emptiesRoot has no keys after a mergeTree becomes one level shorter

Worked example

The same steps the visualizer animates for any input.

Order 4 (max 3 keys per node).
Insert 10, 20, 30: root is [10 | 20 | 30].
Insert 40: root would hold 4 keys, so it splits.
  Median 30 moves up: new root [30], children [10 | 20] and [40].
All leaves are on the same level.

B-Tree FAQ

Quick answers.

What is a B-tree?

A self-balancing search tree where each node holds multiple sorted keys and can have multiple children, with all leaves on the same level.

What does the order of a B-tree mean?

The order m is the maximum number of children a node can have. A node holds at most m-1 keys.

How does a B-tree split?

When a node has too many keys, it splits around the median. The median moves up to the parent and the two halves become separate nodes.

How does B-tree deletion work?

Remove the key. If the node is too small, borrow a key from a sibling through the parent, or merge with a sibling if both are at the minimum.

Why are B-trees used in databases?

Wide nodes make the tree very shallow, so finding a key needs only a few disk reads.

What is the time complexity?

Search, insert and delete are all O(log n).

B-tree vs B+ tree?

A B-tree stores keys in internal nodes too. A B+ tree stores all keys in linked leaves, which makes range scans fast.

Is the visualizer free and private?

Yes. Free, no signup, and everything runs in your browser.

More free tools from KickSolve

Other tree visualizers.