DIY: Binary Search Tree Iterator
Develop a binary search tree iterator by implementing next and has_next methods to traverse the tree in ascending order. Understand how to work with BST nodes and manage iteration state in Rust, enabling efficient in-order traversal for coding interview problems.
We'll cover the following...
We'll cover the following...
Problem statement
In this challenge, you have to implement a binary search tree iterator class called BSTIterator. The iterator will be initialized by the root node of the BST. You have to implement two methods:
next(): This will return the next smallest number in the BST.