public class BinarySearchTree {
…
public boolean remove(int value) {
if (root == null)
return false;
else {
if (root.getValue() == value) {
BSTNode auxRoot = new BSTNode(0);
auxRoot.setLeftChild(root);
boolean result = root.remove(value, auxRoot);
root = auxRoot.getLeft();
return result;
} else {
return root.remove(value, null);
}
}
}
}
public class BSTNode {
…
public boolean remove(int value, BSTNode parent) {
if (value < this.value) {
if (left != null)
return left.remove(value, this);
else
return false;
} else if (value > this.value) {
if (right != null)
return right.remove(value, this);
else
return false;
} else {
if (left != null && right != null) {
this.value = right.minValue();
right.remove(this.value, this);
} else if (parent.left == this) {
parent.left = (left != null) ? left : right;
} else if (parent.right == this) {
parent.right = (left != null) ? left : right;
}
return true;
}
}
public int minValue() {
if (left == null)
return value;
else
return left.minValue();
}
}
In the last few lines of the remove(int, node) function...There are a few lines I don't understand...
} else if (parent.left == this) {
parent.left = (left != null) ? left : right;
} else if (parent.right == this) {
parent.right = (left != null) ? left : right;
}
in the second line.... what is the parent.left = (left != null) ? left:right?

I'm guessing it's saying something like if parent.left...while left != null, swap the left and right...But I don't fully understand it.. Please explain! Thanks!