B+ Tree
Insert, delete, search in a B+ tree visualiser
About This Simulation
This B+ tree simulator lets you choose the order of the tree, insert and delete keys, and watch nodes split, merge and borrow keys while the tree stays balanced.
Features
- Choose the order (maximum number of children) of the tree
- Insert, delete and search keys
- Node splits, merges and redistribution shown step by step
- Linked leaf nodes for range queries
- Pan, zoom and fullscreen view for large trees
Explanation
A B+ tree is a balanced search tree in which every key is stored in the leaf nodes, internal nodes only hold copies of keys that guide the search, and the leaves are linked together in sorted order. All leaves are at the same depth.
How it works
- Search: start at the root and follow the child pointer whose key range contains the target until you reach a leaf.
- Insert: add the key to the correct leaf in sorted order. If the leaf overflows, split it into two and copy the first key of the new right leaf up into the parent.
- If an internal node overflows, split it and move its middle key up. If the root splits, the tree grows one level taller.
- Delete: remove the key from its leaf. If the leaf has too few keys, borrow a key from a sibling or merge with it, and update the parent.
- Range query: find the first key with a normal search, then follow the leaf links to the right.
Why it matters
B+ trees are the index structure used by most relational databases (MySQL InnoDB, PostgreSQL, SQL Server) and file systems, because their high fan-out keeps the tree shallow and minimises disk reads. They are a key topic in database courses such as CSE370.
Frequently Asked Questions
What is the difference between a B tree and a B+ tree?
In a B tree, keys and data can be stored in any node. In a B+ tree, all data is in the leaves, internal nodes only guide the search, and the leaves are linked, which makes range queries and sequential scans much faster.
What is the order of a B+ tree?
The order is the maximum number of children an internal node can have. A node of order m holds at most m − 1 keys, and every node except the root must be at least half full.
What is the time complexity of search in a B+ tree?
O(log n) with a base equal to the fan-out, so search, insert and delete all take O(log_m n) node visits. With a large order, even millions of keys need only 3 or 4 levels.
Why do databases use B+ trees for indexing?
Each node fits a disk page and holds many keys, so the tree is very shallow and needs few disk reads. Linked leaves make range queries such as BETWEEN and ORDER BY efficient.
Topics covered
- B+ Tree
- Database Indexing
- Node Splitting
- Node Merging and Redistribution
- Balanced Search Trees
- Range Queries
Tags
- b plus tree
- index
- insert
- delete
- order
Related Simulations
Data Structures
Stack (ADT) Simulator
Visualise push, pop, overflow, and underflow operations
Data Structures
Queue (ADT) Simulator
Show enqueue, dequeue, front, rear, overflow, and underflow.
Data Structures
Circular Queue (ADT) Simulator
Demonstrate wrap-around movement of front and rear pointers.
Data Structures
Linked List Simulator
Insert, delete and search in a linked list stored in arrays, with the start and free pointers and every pointer change shown step by step.

