DIY: Binary Search Tree Iterator
Explore how to implement a binary search tree iterator that sequentially returns the next smallest element using next and has_next methods. This lesson equips you with practical skills to solve tree traversal problems commonly asked in coding interviews.
We'll cover the following...
We'll cover the following...
Problem statement
In this challenge, you have to implement a binary search tree iterator module 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()