Understanding iterative minimum search
The iterative algorithm for finding the minimum value is very similar to the recursive algorithm. We replace recursive calls with a loop and keep going left until we reach a leaf node, where the minimum is.
Searching for the minimum value in a binary search tree
Algorithm
- Step 1: While `root` is not `null`, do the following:
- Step 1.1: If the `root` node does not have a `left` child, return it.
- Step 1.2: Else, if the `root` node has a `left` child, update the `root` node to hold the reference of its `left` child.
Liking the course? Check our discounted plans to continue learning.