Overview - Why BST Over Plain Binary Tree
What is it?
A Binary Search Tree (BST) is a special kind of binary tree where each node has a value, and all values in the left subtree are smaller, while all values in the right subtree are larger. A plain binary tree has no such order rules. This ordering helps us find, add, or remove values faster. Without this order, searching or sorting in a binary tree can be slow and inefficient.
Why it matters
Without the BST rules, finding a value in a binary tree means checking many nodes one by one, which wastes time. BSTs make searching quick, like looking up a word in a dictionary instead of flipping pages randomly. This speed is crucial in many applications like databases, file systems, and games where fast data access matters.
Where it fits
Before learning about BSTs, you should understand what a binary tree is and how it stores data. After mastering BSTs, you can explore balanced trees like AVL or Red-Black trees that keep BSTs efficient even when data changes a lot.