Tree Playground

Explore insertion, deletion and lookup in B-trees, red-black trees and skip lists.

About this tool

Explore insertion, deletion and lookup in three ordered sets. Choose a structure, load the example or insert integers from −99999999 to 99999999. Each structure keeps its own input set and key draft. At most 63 distinct keys per set; duplicates leave it unchanged. More adds up to ten distinct random keys from 1–99. TXT exports the selected source sequence, one key per line, without settings or results.

Show reconstructs a saved input set immediately. Insert, Delete, Search or Example also initialize it. Changing a valid B-tree degree rebuilds the same keys directly; invalid degrees hide old output without losing keys. Reset empties only the selected set and retains its key draft and degree. Enter in the key field inserts; Enter in the configuration row shows the set.

Orange links show the route actually taken, including level changes in the skip list. A blue outline marks the exact matching key. In a B-tree, keys in the same node separate the ranges of its child links. Red-black nodes retain their colors. Editing the key clears the previous path. Optional details show sorted keys, count and the actual route: tree levels are depth from the root; skip-list levels start at L0. Large diagrams scroll locally, keeping text readable; smaller diagrams grow up to 2× to use available space. A found node or final predecessor is revealed within the diagram, without scrolling the page.

A B-tree with minimum degree t (2–6) has at most 2t−1 keys per node and at least t−1 outside the root; leaves share a depth. Insertions split full nodes; deletions borrow or merge. Red-black insertion uses rotations and recoloring. Its deletion deliberately rebuilds a valid tree from the remaining sorted keys: individual deletion fixup rotations are not demonstrated. The short deletion message explicitly marks this rebuild.

The skip list promotes with probability 1/2, capped at five levels. Reset and the same insertion order reproduce towers with fixed seed 42. Deletion unlinks actual forward pointers. −∞ is a head sentinel, not a stored key. This is an educational structural model, not a timing benchmark or a comparison using automatically shared datasets.

Only raw mode, degree, per-structure key drafts and source key sequences, and the details preference are saved, up to 100,000 serialized characters. No tree topology, node colors, generator state, operation or search path is saved. Reload/new views wait for an explicit action; already mounted pinned views remain in RAM. Legacy v1 keeps all valid keys as sorted source sequences and discards computed shape/history; rebuilt shapes can differ. Oversized drafts keep the previous saved copy: copy long drafts in each structure before reload. No session Save/Load menu. B-tree lecture; Pugh’s skip lists.