Binary Search Tree Playground

Mr. Tono hangs his gourds by number under the pergola: a real binary search tree from your numbers, search and insert count the gourds compared. What shape…

Why it matters

Search trees sit behind sorted maps and sets, database indexes and autocomplete. Their steps are as many as the tree is high, so its shape decides everything: balanced is O(log n), a chain O(n). That is why AVL and Red-Black trees balance themselves.

The key idea

A tree’s shape is its speed

Common mistakes

Try it in this playground