KickSolve • Free • Private

Binary Search Tree Visualizer

The left subtree contains smaller values, and the right subtree contains greater values than the root. Insert, delete, edit and search with step-by-step animation.

Smaller left, greater rightAll four traversalsLive property checks

How to use the Binary Search Tree Visualizer on KickSolve

Three quick steps, no account needed.

Type a valueEnter a number or short word in the Value box and press Insert. It is compared with each node from the root: smaller goes left, greater goes right. Duplicates are rejected.
Press Insert, Delete, Edit or SearchWatch the animation follow the path from the root. Orange is a new node, red is being deleted and green is found. To delete or edit, type the node in Target or click it in the tree.
Run a traversalUse the traversal buttons to see the output. Inorder always prints the values in sorted order. The Ordered (BST) badge stays green.

Why choose KickSolve

Built for learning, speed and privacy.

Private by designEverything runs in your browser. Nothing you type is ever sent anywhere.
Animated, step by stepWatch every visit and placement as it happens, at a speed you choose.
Ordered, step by stepWatch every comparison as a value walks left or right down the tree.
Undo and experimentStep back through your last 40 changes, or generate a random tree to explore.

What you can do with the Binary Search Tree Visualizer

Everything this tool offers.

InsertWalk down from the root, going left for smaller and right for greater, then attach the value.
DeleteRemove a node. A node with two children takes the smallest value from its right subtree.
EditDelete the old value and insert the new one so the tree stays ordered.
SearchFollow the left or right path from the root and highlight the match.
PreorderRoot, then left, then right.
InorderLeft, root, right. Gives sorted output for a BST.
PostorderLeft, right, then root.
Level orderBreadth first, one level at a time.
Property checksBadges show whether the tree is full, complete, perfect, balanced and ordered.
Copy and downloadCopy the tree as an image or save it as a PNG for notes and slides.
Click to selectClick any node to fill in the target box for delete or edit.
Random and UndoGenerate a random BST, or step back through your changes.

About the Binary Search Tree Visualizer on KickSolve

What it does and how to get the best results.

What is a binary search tree?

A binary search tree (BST) is a binary tree in which every node follows one ordering rule: all values in its left subtree are smaller, and all values in its right subtree are greater. This rule lets a search skip half of the remaining tree at every step.

Key properties

  • Left subtree holds smaller values
  • Right subtree holds greater values
  • The rule holds for every node, not just the root
  • Inorder traversal gives sorted output

Operations and time complexity

Search, insert and delete take O(log n) on average and O(n) in the worst case, when sorted input turns the tree into a chain.

Real-world uses

  • Fast lookup and sorted storage
  • Ordered sets and maps
  • Range queries
  • Base for AVL and red-black trees

Comparing tree shapes? Try the Binary Tree, Balanced Binary Tree or Skewed Tree visualizer.

Worked example: building a small binary search tree

The same steps the visualizer animates for any input.

Insert 50: it becomes the root.
Insert 30: smaller than 50, so it goes left.
Insert 70: greater than 50, so it goes right.
Insert 20, 40, 60, 80: each walks left or right from the root until it finds an empty spot.

Inorder:     20 30 40 50 60 70 80
Preorder:    50 30 20 40 70 60 80
Postorder:   20 40 30 60 80 70 50
Level order: 50 30 70 20 40 60 80

Delete 30, which has two children: 40, the smallest value in its right subtree, takes its place.
Inorder:     20 40 50 60 70 80

Insert 1, 2, 3, 4 in sorted order instead and the tree becomes a skewed chain.

Binary Search Tree traversals compared

When each node is visited relative to its children.

TraversalOrderTypical use
PreorderRoot, left, rightCopying a tree, prefix expressions
InorderLeft, root, rightSorted output from a binary search tree
PostorderLeft, right, rootDeleting a tree, postfix expressions
Level orderLevel by level, left to rightShortest path, printing by depth

BST operations and time complexity

Cost depends on the shape of the tree.

OperationAverage (balanced)Worst case (skewed)
SearchO(log n)O(n)
InsertO(log n)O(n)
DeleteO(log n)O(n)
Minimum or maximumO(log n)O(n)
Inorder traversalO(n)O(n)

BST height: best vs worst case

A balanced BST stays short, a skewed one does not.

NodesBest height (balanced)Worst height (skewed)
111
323
737
15415
31531
63663
1277127
2558255
5119511
1023101023

Binary Search Tree FAQ

Quick answers.

What is a binary search tree?

A binary tree in which, for every node, all values in the left subtree are smaller and all values in the right subtree are greater than the node's value.

Why does inorder traversal give sorted output?

Inorder visits the left subtree, then the node, then the right subtree. Because smaller values are always on the left, the values come out in ascending order.

What is the time complexity of a binary search tree?

Search, insert and delete take O(log n) on average when the tree is balanced and O(n) in the worst case, when it is skewed into a chain.

How is a node deleted from a BST?

A leaf is simply removed. A node with one child is replaced by that child. A node with two children takes the smallest value from its right subtree, and that smaller node is then removed.

Does a binary search tree allow duplicate values?

Definitions vary. This visualizer rejects duplicates so the left and right rules stay strict.

What is the difference between a binary tree and a binary search tree?

A binary tree only limits each node to two children. A binary search tree adds the ordering rule, so a search can ignore half of the remaining tree at each step.

When does a BST become skewed?

When values arrive in sorted order. Inserting 1, 2, 3, 4 gives a right skewed chain with height 4, and searching it costs O(n).

How does the visualizer search and insert?

It starts at the root and compares the value with each node. Smaller goes left and larger goes right, until the value is found or an empty spot is reached. The path is highlighted step by step.

How do I edit a node in the visualizer?

Type the existing node in Target and the new value in Value, then press Edit. The old value is deleted and the new one is inserted, so the tree stays ordered.

What is the difference between a BST and an AVL tree?

An AVL tree is a BST that rotates nodes after every insert and delete to keep the height small. A plain BST has no rebalancing, so it can degrade into a chain.

Can I undo a change?

Yes. Press Undo to step back through your last 40 changes. Clear and Random can also be undone.

Is the visualizer free and private?

Yes. It is free with no signup, and everything runs in your browser. Nothing you type is sent to a server.

More free tools from KickSolve

Other tree visualizers.