[Naive Approach] Using Inorder Traversal - O(n) Time and O(n) Space
The idea is to use the property of BST which says inorder traversal of a binary search tree always returns the value of nodes in sorted order. So the 1st value in the sorted vector will be the minimum value which is the answer.
Output
1
[Better Approach] Using Recursion - O(h) Time and O(h) Space
The idea is to start from the root and keep traversing the left child recursively (or iteratively) until a node has no left child. This node contains the minimum value in the BST.
Output
1
[Expected Approach] Using Iterative Way - O(h) Time and O(1) Space
The idea is that in a Binary Search Tree (BST), the left child of a node is always smaller than the root. This ensures that the node whose left pointer is NULL must hold the minimum value in the tree. The leftmost node will always contain the smallest element.