Implement an iterator over a BST with:
BSTIterator(root): Initialize with BST rootnext(): Return the next smallest elementhasNext(): Return whether next element exists
Both operations should run in average time and use memory.
Example: For BST , calling next() repeatedly should return .
This tests your understanding of controlled iteration versus full traversal. Constraints: up to nodes, at most calls total.