This is my code for adding and removing from a binary tree but apparently its not complete can anyone tell me what to do to make it complete tree?
public void add(IBinaryTreeNode<E> e) {
if (getRoot() == null) {
setRoot(e);
} else {
//SAME HERE
IBinaryTreeNode<E> node = getLastNode();
node.setRightChild(e);
e.setParent(node);
}
setLastNode(e);
setSize(getSize() + 1);
}
@Override
public IBinaryTreeNode<E> remove() {
IBinaryTreeNode<E> node = getLastNode();
if (!node.equals(getRoot())) {
//IM SURE SOMETHING WRONG HERE
node.getParent().setRightChild(null);
setLastNode(node.getParent());
} else {
setLastNode(null);
setRoot(null);
}
node.setParent(null);
setSize(getSize() - 1);
return node;
}