Binary Search Trees · Search · Traversals

BST & Tree Traversal Visualizer

Explore how insertion order shapes a binary search tree. Generate a random tree or a deliberately skewed tree, then step through every comparison involved in adding, removing, or searching for a key. Traversals can also be explored one visit at a time.

Set up

Choose an operation

Step through

Begin prepares an operation. Step advances one comparison or link change. For traversal, select an order, choose Start traversal, then Visit next or Play.

Nodes: 0
Tree height: 0
Traversal visits: 0 / 0
Shape: Empty

Binary search tree

100%

Smaller keys go left; larger keys go right. A skewed BST has height n, so search can take O(n) comparisons instead of O(log n) in a balanced tree.

Traversal

Operation trace

Generate a tree or add a key to get started.

The active node is highlighted at every comparison. Removal with two children first steps through the left branch of the right subtree to find the inorder successor. Inorder visits left, node, right and returns sorted keys; the other traversal orders are listed above.

The tree is empty.