Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.
Calling next() will return the next smallest number in the BST.
Note: next() and hasNext() should
run in average O(1) time and uses O(h) memory, where h is the height of the tree.
{优快云:CODE:635834}

本文介绍了一种在二叉搜索树(BST)上实现迭代器的方法。该迭代器初始化时接收BST的根节点,并能返回树中下一个最小的数值。强调了next()和hasNext()方法在平均时间复杂度为O(1),使用O(h)内存的情况下运行,其中h为树的高度。
1212

被折叠的 条评论
为什么被折叠?



