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 BSTs find, add, or remove values faster than plain binary trees. Understanding why BSTs are better helps us choose the right tool for storing and searching data.
Why it matters
Without BSTs, searching for a value in a binary tree could take a long time because we might have to check every node. BSTs solve this by keeping data sorted, so we can skip large parts of the tree when searching. This makes programs faster and more efficient, especially when working with large amounts of data like contacts, files, or game scores.
Where it fits
Before learning why BSTs are better, you should understand what binary trees are and how they store data. After this, you can learn about balanced BSTs like AVL or Red-Black trees, which keep the tree efficient even as it grows.
