AlgoPrecision

Tree Visualizer

Binary Search Trees

Build a BST, trace search decisions, and step through inorder traversal with highlighted nodes and synced pseudocode.

O(h)
4218672991543673

Step Note

Search for 42 from the root.

Details
function search(root: Node | null, target: number) {
  let current = root
  while (current) {
    if (current.value === target) return current
    if (target < current.value) current = current.left
    else current = current.right
  }
  return null
}