DIY: Binary Search Tree Iterator
Solve the interview question "Binary Search Tree Iterator" in this lesson.
We'll cover the following
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.
has_next(): This will return
trueif the next smallest number exists in the tree.