DIY: Binary Search Tree Iterator
Understand how to implement a Binary Search Tree iterator that supports next smallest element retrieval and checks for remaining elements. This lesson helps you master iterator design with efficient traversal techniques, preparing you for related coding interview questions.
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.