Advertisement
Aldin-SXR

findMax()

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