Implement an iterator over a BST with: - BSTIterator(root): Initialize with BST root - next(): Return the next smallest element - hasNext(): 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.