"Stop searching linearly. BSTs leverage the power of divide-and-conquer to find any piece of data in logarithmic time."
"Observe the Logarithmic Elimination in real-time."
"The rules that maintain the search efficiency."
"Every node in the **Left Subtree** must have a value smaller than the parent node."
"Every node in the **Right Subtree** must have a value larger than the parent node."
"By default, duplicate values are not allowed. Each entry must provide a unique search key."
"BSTs are only fast if they are balanced. If you insert sorted data (1, 2, 3...), your tree becomes a Linked List."
When the tree is **Skewed**, search is no longer logarithmic. It becomes linear crawl.
The height is kept minimal ($H = \log N$), maximizing the discard rate per step.
1function search(root, target) {2 // BASE CASES3 if (!root) return null;4 if (root.val === target) return root;5 6 // RECURSIVE LOGIC7 if (target < root.val) {8 return search(root.left, target);9 } else {10 return search(root.right, target);11 }12}