private Node remove(Node node , A a){
if (node == null)
return null;
if (a.compareTo(node.a) < 0){
node.left = remove(node.left , a);
return node;
}else if (a.compareTo(node.a) > 0){
node.right = remove(node.right , a);
return node;
}else{
if (node.left == null){
Node rightNode = node.right;
node.right = null;
size --;
return rightNode;
}
if (node.right == null){
Node leftNode = node.left;
node.left = null;
size --;
return leftNode;
}
Node successor = findMin(node.right);
//successor.left = node.left;
**1 successor.right = removeMin(node.right);
2 successor.left = node.left;
node.right = node.left = null ;
return successor;
}
}
波波老师,为什么1和2这两行交换位置这个方法就出错了?