Finding the minimum value

As a binary search tree stores data in a sorted way, we can always find the smaller data in the left nodes and the bigger ones in the right node. So, finding the minimum value will require us to visit all the left nodes from the root node until we find the left-most node and its value. Here are the steps for finding the minimum value:

  1. Start with the root node and set it as the current node.
  2. If the current node is empty, return false.
  3. Go to the left and set the left as the current node.
  4. If the current node does not have a left node, go to step 5; otherwise, continue to step 4.
  5. Continue to step 3 until all the left nodes are visited.
  6. Return the current node.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset