Binary Search Tree
0% completed
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 the leftmost node (the node with no left child), which is where the minimum is.
Searching for the minimum value in a binary search tree
Algorithm
- Step 1: While
rootis notnull, do the following:
- Step 1.1: If the
rootnode does not have aleftchild, return it.- Step 1.2: Else, if the
rootnode has aleftchild, update therootnode to hold the reference of itsleftchild.
Liking the course? Check our discounted plans to continue learning.