FlowLab Logo

BST Visualizer

Select an action
 
30154510224060
Logs
No operations yet
Notes
BST (Binary Search Tree): Each node has at most two children. Values left are less, right are greater.
Insert: Traverses from root, builds path, inserts at leaf.
Find: Traverses from root, highlights path.
Remove: Finds, then removes node, handles re-linking children.
Random: Does a random insert or remove.
BST limit: 15 (simulates overflow)
Overflow and "not found" events are visually shown.
Controls are disabled during animation for safety.
Try inserting, finding, removing, or random to see BST changes!
Implementation (TypeScript)
class BST {
  root: Node | null = null;
  insert(value: number) { /* ... */ }
  find(value: number) { /* ... */ }
  remove(value: number) { /* ... */ }
}
About BSTs
A BST is a binary tree where for each node, all left descendants are less, right descendants are greater.
Applications:
  • Searching/sorting sets
  • Symbol tables/dictionaries
  • Range queries
Main operations:
  • insert(value): Add value at correct position
  • find(value): Search for a value
  • remove(value): Remove value, rebalance if needed
Unbalanced BSTs can degenerate to linked lists if inserted in sorted order.