Understanding iterative lower bound search
Like the search algorithm, we can find the lower bound for a given value in a binary search tree iteratively. Since we only move from top to bottom in the tree and do not backtrack, we can replace the recursive function calls with loops to get an algorithm to find the lower bound of value in a binary search tree iteratively.
Algorithm
The iterative algorithm for finding the lower bound is similar to the recursive algorithm. We can piggyback on the iterative search algorithm we learned earlier and keep track of the most recent value seen so far that is greater than or equal to the given value as we go down the tree along the search path. The cases we may encounter are the same as those for the recursive algorithm.
Liking the course? Check our discounted plans to continue learning.