Binary Search Tree Visualizer — Insert, Search, Delete
Interactive binary search tree — insert, search, delete with an animated tree, step controls and pseudocode. Runs in your browser.
Pseudocode
Run an operation to see its steps.
Avg · Worst
How to use
- 1 Type a number and press Insert to add it — watch the search for its spot.
- 2 Press Search to trace the path to a value, or Delete to remove one.
- 3 Use Random to insert a random value, or Clear to start over.
- 4 Step back and forward through any operation, and follow the highlighted pseudocode.
Why use this tool
- See the BST rule in action: smaller values go left, larger go right.
- Watch all three delete cases — leaf, one child, and two children (in-order successor).
- Understand why a balanced BST gives O(log n) search and an unbalanced one degrades to O(n).
- Runs entirely in your browser. No signup, no uploads.
Frequently asked questions
What is a binary search tree?
A binary search tree (BST) is a binary tree where every node’s left subtree holds smaller values and its right subtree holds larger values, so an in-order traversal yields the values in sorted order.
What is the time complexity of BST operations?
Insert, search, and delete are O(h), where h is the tree height — O(log n) when balanced, but O(n) in the worst case (a degenerate, list-like tree).
How does deletion work when a node has two children?
The node’s value is replaced by its in-order successor (the smallest value in its right subtree), and that successor node is then removed — preserving the BST ordering.
How do I keep a BST balanced?
Use a self-balancing variant such as an AVL tree or a red-black tree, which perform rotations on insert/delete to keep the height O(log n).
What is Binary Search Tree Visualizer?
A Binary Search Tree Visualizer is an interactive tool that animates insert, search, and delete on a BST — a binary tree where every left subtree holds smaller values and every right subtree holds larger values. It shows the traversal path for each operation and all three deletion cases.
Features
Insert / search / delete
Animate each operation as it walks down the tree by key comparison.
Complexity
Per operation O(h): average O(log n), worst O(n) (unbalanced). Space O(n). Not self-balancing.
100% private
Runs entirely in your browser — nothing is uploaded.
Example
Input
insert 5, 3, 8, 1
Output
5 (root); 3 ← left of 5; 8 → right of 5; 1 ← left of 3
Common use cases
-
1
Learn tree operations
See how insert and search follow the BST ordering property.
-
2
Why balancing matters
Watch sorted inserts degrade the tree to O(n) and motivate AVL/red-black trees.
-
3
In-order traversal
Understand how an in-order walk yields sorted keys.
Zerethon's binary search tree visualizer animates insert, search, and delete on a BST in your browser, where each node's left subtree holds smaller keys and the right holds larger. Operations take O(h) time where h is the tree height: O(log n) on a balanced tree but O(n) in the worst case (a degenerate, list-like tree). Space is O(n). This BST is not self-balancing.
- Category
- Algorithm
- Pricing
- Free
- Privacy
- Browser-based
- Signup
- Not required
References
- MIT OCW 6.006 — Introduction to Algorithms (CLRS) — MIT OpenCourseWare
- VisuAlgo — Binary Search Tree — VisuAlgo (NUS)
- Binary search tree — Wikipedia
Privacy
Your data never leaves your browser unless explicitly stated. Binary Search Tree Visualizer runs entirely client-side — no server upload, no logging, no tracking of your input.
New to this? Read the step-by-step explanation with Big-O analysis: Learn Data Structures →
Related tools
Bubble Sort Visualizer
Animated bubble sort with step controls, speed, custom input, live comparison/swap counters and pseudocode. Runs entirely in your browser.
Open toolInsertion Sort Visualizer
Animated insertion sort with step controls, speed, custom input, live comparison/write counters and pseudocode. Runs in your browser.
Open toolSelection Sort Visualizer
Animated selection sort with step controls, speed, custom input, live comparison/swap counters and pseudocode. Runs in your browser.
Open toolMerge Sort Visualizer
Animated merge sort with step controls, speed, custom input, live comparison/write counters and pseudocode. Runs in your browser.
Open toolBuild, share, and grow on Zerethon Social
Free signup. Earn points, collect achievements, and connect with creators worldwide.