← Algo Playground
TREES · ORDERED SEARCH

Every comparison picks a branch.

Smaller values go left. Larger values go right. Watch that simple rule build a searchable tree.

BINARY SEARCH TREE

Left < node < right

Unbalanced BST
Click a node to select its value.
NodeComparing / visitingSuccessorResult
Ready

Try searching for 60, inserting 45, or deleting 50 to explore successor replacement.

TRAVERSAL OUTPUT
Run a traversal to reveal its visit order.
NODES0
HEIGHT (EDGES)—
MIN / MAX—
COMPARISONS0
OPERATION TRACE

Follow the decisions.

  1. Your next operation will appear here.
WHY THE SHAPE MATTERS

Same values. Different search costs.

Insert, search, and delete take O(h), where h is the tree height. A balanced shape has height O(log n); sorted insertions can produce a chain with height O(n). This tree does not automatically rebalance.

Leaf: remove it directly.

One child: promote that child.

Two children: replace the value with the smallest value in the right subtree, then remove that successor from its old position.

Inorder traversal returns values in ascending order. A single node has height 0.