Overview - Why BST Over Plain Binary Tree
What is it?
A Binary Tree is a structure where each node has up to two children, but the order of values is not fixed. A Binary Search Tree (BST) is a special kind of binary tree where every node's left child has a smaller value and the right child has a larger value. This order helps us find, add, or remove values faster than in a plain binary tree. BSTs keep data sorted and allow quick searching.
Why it matters
Without the order rules of a BST, searching for a value in a plain binary tree can take a long time because you might have to check every node. BSTs solve this by organizing data so you 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 phone books, databases, or game leaderboards.
Where it fits
Before learning about BSTs, you should understand what a binary tree is and how nodes connect. After BSTs, you can learn about balanced trees like AVL or Red-Black Trees, which keep BSTs efficient even when many insertions and deletions happen.