Essay
An executable binary search tree
A compact Go example for exploring insertion, lookup, and traversal in a binary search tree.
- Algorithms
- Go
- Projects
A binary search tree keeps smaller values in the left subtree and larger values in the right subtree. That invariant makes insertion and lookup follow the same decision at every node.
The interactive example below is part of the executable-note experiment. Change the inserted values or traversal order and run it again without leaving the page.
Balanced trees can keep lookup near . A plain tree can still degrade to when values arrive in sorted order, which makes input shape part of the design—not just an implementation detail.