Guest User

Untitled

a guest
Jan 21st, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. private K key;
  2. private V value;
  3. Tree<K, V> left;
  4. Tree<K, V> right;
  5. private boolean isMax = false;
  6.  
  7. public K max() throws EmptyTreeException {
  8. if(right.toString()!=""){
  9. return right.max();
  10. }
  11. else
  12. this.isMax = true;
  13. return this.key;
  14. }
  15.  
  16. public String toString() {
  17. String result = "";
  18. result+=(this.left.toString());
  19. result+=this.key;
  20. result+="=>";
  21. result+=this.value;
  22. if(this.isMax != true){
  23. result+=" ";
  24. }
  25. result+=this.right.toString();
  26. return result;
  27. }
Add Comment
Please, Sign In to add comment