Chapter 10 · SimulationB-Tree Simulator ? ← Chapter 10 Minimum degree (t) 2 · up to 3 keys 3 · up to 5 keys 4 · up to 7 keys Value Insert Search Delete In-order traversal Load example Random Reset Stop Example B-tree loaded. Close B-Tree Simulator In a B-tree of minimum degree t, every node except the root holds between t − 1 and 2t − 1 keys, the keys inside a node are sorted, and all leaves sit at the same depth. Wide nodes keep the tree shallow, which is why databases and file systems use B-trees. How to use it Pick a Minimum degree (t). Changing it reloads the example tree with the new t and discards the current tree. Type a Value and press Insert, Search or Delete. In-order traversal lists the keys in sorted order. Load example, Random and Reset replace the whole tree (at most 15 keys). Stop interrupts the animation and restores the tree. Insertion A new key always goes into a leaf. On the way down, every full node (2t − 1 keys) is split and its median key moves up to the parent. Splitting the root makes the tree one level taller. Deletion A key in an internal node is replaced by its predecessor or successor, or its two children are merged around it. Before descending into a child that has only t − 1 keys, the algorithm borrows a key from a sibling through the parent, or merges the child with a sibling. Complexity The height is O(logt n), so search, insertion and deletion each visit O(logt n) nodes.