Binary Tree Visualiser

Step through a binary search tree one comparison at a time: search, insert, delete with its awkward two-child case, the four walks, and the classics an interview asks about — height, balance, longest path, mirror image, valid search tree, path sum, kth smallest, lowest common ancestor. The diagram, the call stack and the highlighted line of code are all read from the same trace, so they never disagree.

A frontend app built by Ananda Rizki. More of them at Labs.

Treeviz

Looking for 37 among 7 nodes. Start at the root, 50.

Comparisons
0
Nodes visited
0
12253750627587
  • Examining
  • Walked past
  • The answer
  • Finished
  • Untouched
02let node = root;
Labs — by Ananda Rizki

Simulator

Binary Tree Visualiser

Sixteen operations on a binary search tree, stepped one comparison at a time: search, insert, delete with its awkward two-child case, invert, the four traversals, and eight questions asked about a tree rather than done to one — height, balanced, longest path, mirror image, valid search tree, path sum, kth smallest, lowest common ancestor. Those last eight are grouped together because they are one idea underneath: a fold from the leaves upward, where a node cannot answer until both children have, and the badge under each node is that node's returned value. A frame is a whole snapshot of the tree rather than a diff, and node ids are stable across frames, so the diagram animates instead of blinking when an operation replaces the root.

Built by Ananda Rizki, a frontend developer — one of the small web apps he writes for fun at Labs.