FlowLab Logo

BST Search Visualizer

SlowFast
515
(8)
Current Node
Search Path
Target Value
Found
Other
Inorder:
Operation Logs
No operations yet
Algorithm Info
Time Complexity: O(log n) (if balanced), O(n) (worst case)
Space Complexity: O(1)
Best Case: O(1) - found at root
Worst Case: O(n) - unbalanced tree
How it works: Traverses BST following left/right pointers guided by value.
When to use: Fast search in sorted binary tree.
Implementation
function bstSearch(root, target) {
  let node = root;
  while (node) {
    if (node.value === target) return node;
    node = target < node.value ? node.left : node.right;
  }
  return null;
}