Advertisement
Aldin-SXR

findMin()

May 12th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.32 KB | None | 0 0
  1. /* Find the minimum key of the BST */
  2. public Key findMin() {  
  3.    return findMin(root).key;                                    // 1
  4. }  
  5.    
  6. /* Private findMin() method */
  7. private Node<Key, Value> findMin(Node<Key, Value> x) {
  8.    if (x.left == null) {                                        // 2
  9.        return x;                                                // 2
  10.    }
  11.    return findMin(x.left);                                      // 3
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement