gon2

Untitled

Mar 7th, 2018
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1.    
  2.     // mín min og max föll:
  3.     public Key min() {
  4.         if (isEmpty()) throw new NoSuchElementException("calls min() with empty symbol table");
  5.  
  6.         Node n = root;
  7.         // förum eins langt til vinstri og við getum:
  8.         while (n.left != null) {
  9.             n = n.left;
  10.         }
  11.         return n.key;
  12.     }
  13.  
  14.     public Key max() {
  15.         if (isEmpty()) throw new NoSuchElementException("calls max() with empty symbol table");
  16.        
  17.         Node n = root;
  18.         // förum eins langt til hægri og við getum:
  19.         while (n.right != null) {
  20.             n = n.right;
  21.         }
  22.         return n.key;        
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment