What if you could find any name in a huge tree without searching every branch?
Why BST Over Plain Binary Tree in DSA Typescript - The Real Reason
Imagine you have a big family tree drawn on paper with names scattered randomly. You want to find a cousin's name quickly, but you have to look through every name one by one.
Searching through a random tree means checking many nodes without any order. This takes a lot of time and can be confusing, especially if the tree is large.
A Binary Search Tree (BST) keeps names in order: smaller names go left, bigger names go right. This order helps you skip many nodes and find names faster.
function searchNode(node, value) {
if (!node) return false;
if (node.value === value) return true;
return searchNode(node.left, value) || searchNode(node.right, value);
}function searchBST(node, value) {
if (!node) return false;
if (node.value === value) return true;
if (value < node.value) return searchBST(node.left, value);
else return searchBST(node.right, value);
}BSTs let you find, add, or remove items quickly even in big collections by using order to skip unnecessary checks.
Think of a phone book sorted by last names. You don't flip every page; you jump to the section starting with the letter you want. BST works like that for data.
Random trees require checking many nodes, making search slow.
BSTs keep data ordered to speed up search and updates.
Using BSTs is like having a sorted list that helps you find things faster.