Advertisement
kimo12

Untitled

Mar 22nd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. private void rightRight(Node<T> check, Node<T> child, Node<T> parent) {
  2. boolean right = false, noParent = false;
  3. check.setRightChild(null);
  4. child.setParent(null);
  5. if (parent == null)
  6. noParent = true;
  7. else if (parent.getValue().compareTo(check.getValue()) < 0)
  8. right = true;
  9.  
  10. if (!noParent) {
  11. if (right)
  12. parent.setRightChild(child);
  13. else
  14. parent.setLeftChild(child);
  15. }
  16. if (child.hasLeftChild())
  17. check.setRightChild((Node<T>) child.getLeftChild());
  18. child.setLeftChild(check);
  19. check.setParent(child);
  20. if(check==root) root=child;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement