DAILYBRAINARC / Algorithm LabExplore all ↗
DATA STRUCTURES · INTERACTIVE · V0.807

Binary Search Tree Studio

Build a tree. Follow each comparison. Master the structure.

30original
practice puzzles
RUNS LOCALLY · NO SIGN-UP

LIVE STRUCTURE

Binary search tree

7NODES3HEIGHT0COMPAREDYESBALANCED*
Compared Selected Other

TRAVERSALS · CLICK TO ANIMATE

In-order: 20 → 30 → 40 → 50 → 60 → 70 → 80

TREE TOOLS

Understand a BST · deletion cases, height, balance and complexity

Ordering invariant: Every node is greater than every key in its left subtree and less than every key in its right subtree. Duplicate keys are skipped in this set-style lab.

Delete: A leaf is removed directly. A node with one child is replaced by that child. A node with two children is replaced by its in-order successor (the smallest key in its right subtree).

Time: Search, insert and delete take O(h). A balanced tree has h near log₂(n); inserting sorted values creates a chain and O(n) worst-case. This lab does not auto-rotate or rebalance.

*Balanced here means every node has child-subtree heights differing by at most one (AVL-style height balance); it is a measure, not automatic AVL behavior.