5

Configure inputs and press Visualize to begin.

Operation History
Built BST: [50, 30, 70, 20, 40, 60, 80, 10, 35]
Pseudocode & Implementations
1 approach

Standard BST with recursive insert, search, and delete.

BST-INSERT(root, val):
  IF root == NULL: RETURN new Node(val)
  IF val < root.val: root.left  = BST-INSERT(root.left, val)
  IF val > root.val: root.right = BST-INSERT(root.right, val)
  RETURN root

BST-SEARCH(root, val):
  IF root == NULL OR root.val == val: RETURN root
  IF val < root.val: RETURN BST-SEARCH(root.left, val)
  RETURN BST-SEARCH(root.right, val)
Complexity Analysis

Time Complexity

Best Case
LogarithmicO(log n)
Average
LogarithmicO(log n)
Worst Case
LinearO(n)
Space (aux)
LinearO(n)
treesearchordered
About

A binary tree where every left child < parent < every right child. Supports efficient search, insert, and delete.

Key Insight

Degenerates to O(n) with sorted input — the motivation for balanced BSTs like AVL and Red-Black trees.

Use Cases

Ordered setsMapsDatabasesPriority queues

Tree Stats

Nodes

9

Height

4