What if you could find the smallest item instantly without searching everything?
Why BST Find Minimum Element in DSA C++?
Imagine you have a messy pile of books with no order. You want to find the oldest book, but you have to check every single one by hand.
Looking through every book one by one takes a lot of time and effort. You might miss some or get tired, making mistakes easy.
A Binary Search Tree (BST) keeps books sorted so the oldest book is always on the leftmost side. You just follow the left path to find it quickly and easily.
int findMin(int arr[], int size) {
int min = arr[0];
for(int i = 1; i < size; i++) {
if(arr[i] < min) min = arr[i];
}
return min;
}Node* findMin(Node* root) {
while(root->left != nullptr) {
root = root->left;
}
return root;
}This lets you find the smallest value instantly without checking every item, saving time and effort.
In a phone contact list sorted by name, finding the first contact alphabetically is like finding the minimum in a BST.
Manual search is slow and error-prone.
BST structure keeps data sorted for quick minimum search.
Following left children leads directly to the minimum element.