public void insertLeft(BTNodeWithParent<T> left) { left.setLeft(this.getLeft().getLeft()); left.setRight(this.getLeft().getRight()); left.setParent(this); left.getLeft().setParent(left); left.getRight().setParent(left); this.setLeft(left); }
public void insertRight(BTNodeWithParent<T> right) { right.setLeft(this.getRight().getLeft()); right.setRight(this.getRight().getRight()); right.setParent(this); right.getLeft().setParent(right); right.getRight().setParent(right); this.setRight(right); }
/* * Find the data downwards from the node specified */ public static <T> boolean findData(BTNodeWithParent<T> root, T data) { if (root == null) { return false; } else if (root.getData() == data) { return true; } else { return (findData(root.getLeft(), data) || findData(root.getRight(), data)); } }