Binary Search Tree Visualizer — Interactive BST Tool
Insert, delete, and search nodes in a Binary Search Tree with animated step-by-step visualization. Watch four traversal algorithms — In-order, Pre-order, Post-order, and Level-order — highlight each node in sequence. Export as PNG or animated GIF.
Operations
- Insert — Animates the search path before inserting the new node as a leaf.
- Delete — Handles all three BST deletion cases: leaf node, one child, two children (successor replacement).
- Search — Highlights the comparison path from root to target node.
Traversals
- In-order (Left-Root-Right) — Visits nodes in sorted ascending order. Used to extract sorted data from a BST.
- Pre-order (Root-Left-Right) — Used for tree serialization and copying.
- Post-order (Left-Right-Root) — Used for deleting a tree or evaluating expression trees.
- Level-order (BFS) — Visits nodes level by level. Used for shortest path in unweighted trees.
Related Tools
FAQ
What is a Binary Search Tree?
A BST is a binary tree where every node's left subtree contains only values less than the node, and the right subtree contains only values greater. This property enables O(log n) search, insert, and delete on a balanced tree.
What is tree height?
Height is the number of edges on the longest path from root to a leaf. A balanced BST of n nodes has height O(log n). A degenerate (linear) BST has height O(n).
What is In-order traversal used for?
In-order traversal of a BST always produces nodes in sorted ascending order. This is why BSTs are used to implement sorted sets and maps in many programming languages.