KickSolve • Free • Private

Binary Tree Visualizer

A tree in which each node can have at most 2 children (left and right). Insert, delete, edit and search with step-by-step animation.

Left and right childrenAll four traversalsLive property checks

How to use the Binary Tree Visualizer on KickSolve

Three quick steps, no account needed.

Type a valueEnter a number or short word in the Value box. Leave the parent empty to fill the first free slot in level order, or pick a parent and a side.
Press Insert, Delete, Edit or SearchWatch the animation walk through the tree. Orange is a new node, red is being deleted and green is found.
Run a traversalUse the traversal buttons to see preorder, inorder, postorder and level order output, and check the property badges on the right.

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.
Left and right controlChoose the parent and the side for every new node, or let the tree fill level by level.
Undo and experimentStep back through your last 40 changes, or generate a random tree to explore.

What you can do with the Binary Tree Visualizer

Everything this tool offers.

InsertAdd a node under a parent on the left or right, or in the first free slot.
DeleteRemove a node. The deepest node takes its place so the shape stays tidy.
EditChange a node's value in place without moving it.
SearchScan the tree and highlight the first node that matches.
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, edit or insert.
Random and UndoGenerate a random tree, or step back through your changes.

About the Binary Tree Visualizer on KickSolve

What it does and how to get the best results.

What is a binary tree?

A binary tree is a tree data structure in which every node has at most two children, called the left child and the right child. It is the base for binary search trees, heaps and expression trees.

Key properties

  • Each node has 0, 1 or 2 children
  • Children are named left and right
  • Height can range from log n to n
  • Supports preorder, inorder, postorder and level order traversal

Operations and time complexity

Traversal and search take O(n) because a plain binary tree has no ordering. Insert at the first free slot and delete using the deepest node are O(n) to locate.

Real-world uses

  • Expression parsing
  • Binary search trees and heaps
  • Decision trees
  • Huffman coding

Comparing tree shapes? Try the Full Binary Tree, Complete Binary Tree, Perfect Binary Tree or Balanced Binary Tree visualizer.

Worked example: building a small binary tree

The same steps the visualizer animates for any input.

Insert 1: it becomes the root.
Insert 2: first free slot in level order, so it is the left child of 1.
Insert 3: next free slot, so it is the right child of 1.
Insert 4: the root is full, so it is the left child of 2.

Preorder:    1 2 4 3
Inorder:     4 2 1 3
Postorder:   4 2 3 1
Level order: 1 2 3 4

The same tree gives four different orders depending on when the root is visited.

Binary 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

Types of binary trees

The shapes the property badges check for.

TypeRule
FullEvery node has 0 or exactly 2 children
CompleteAll levels filled except the last, which fills from the left
PerfectAll internal nodes have 2 children and all leaves share one level
BalancedLeft and right heights differ by at most 1 at every node
Binary search treeLeft values are smaller and right values are larger

Nodes per binary tree height

The fewest and most nodes a binary tree of each height can hold.

HeightMinimum nodesMaximum nodes
111
223
337
4415
5531
6663
77127
88255
99511
10101023

Binary Tree FAQ

Quick answers.

What is a binary tree?

A tree where each node has at most two children, a left and a right child.

What are the binary tree traversals?

Preorder (root, left, right), inorder (left, root, right), postorder (left, right, root) and level order (breadth first).

Is every binary tree a binary search tree?

No. A binary search tree also keeps smaller values on the left and larger values on the right. A plain binary tree has no ordering rule.

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 an ordering rule, so search, insert and delete can run in O(log n) when the tree is balanced.

What is the height of a binary tree?

The height is the number of levels from the root down to the deepest leaf. With n nodes it can range from about log2(n) for a compact tree up to n for a tree that is a straight line.

How many nodes can a binary tree have at most?

A binary tree of height h has at most 2^h - 1 nodes. Height 3 allows 7 nodes and height 4 allows 15.

What is the difference between full, complete and perfect binary trees?

In a full tree every node has 0 or 2 children. A complete tree is filled level by level from the left. A perfect tree has every level completely filled. The property badges in the visualizer check all three.

What is the time complexity of binary tree operations?

Search and traversal take O(n) in a plain binary tree because there is no ordering to follow. Insert at a known parent is O(1) and finding that parent is O(n).

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.