Visualize BST search step by step. Watch the algorithm exploit the BST ordering property to eliminate half the remaining tree at each comparison.
Exploit the BST ordering property: at each node, decide left or right in O(1). Total cost is O(h) where h is tree height.
Compare target with root. If equal → found. If smaller → go left subtree. If larger → go right subtree.
Repeat comparison at each visited node, eliminating half the remaining tree at each step (in a balanced BST).
If node value matches target → return node (highlighted in orange). If we reach null → target is not in the BST.
O(h) time where h = tree height. For a balanced BST h = O(log N). For a degenerate (linked list) BST h = O(N).
No recursion needed: an iterative while loop suffices. Each comparison eliminates one entire subtree from consideration.