Guest User

Untitled

a guest
Jun 25th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1.             if (node.getElement().compareTo(tempNode.getElement()) > 0) {
  2.                 tempNode = tempNode.getRightSubTree();
  3.                 if (tempNode == null) {
  4.                     tempNode.setRightSubTree(node);
  5.                 }
  6.             } else if (node.getElement().compareTo(tempNode.getElement()) < 0) {
  7.                 tempNode = tempNode.getLeftSubTree();
  8.                 if (tempNode == null) {
  9.                     tempNode.setLeftSubTree(node);
  10.                 }
  11.             } else {
  12.                 System.out.println("Duplicate node");
  13.                 return false; // Duplicate node, not added
  14.             }
Add Comment
Please, Sign In to add comment