Hey Leute,
Ich versuche folgende Binary Tree Methode zu implementieren:
public void remove(T data) {
root = remove(root, data);
}
private Nodes<T> remove(Nodes<T> root, T data) {
Nodes<T> current = root;
if (current == null) {
return current;
}
if (current.getData().compareTo(data) > 0) {
current.getLeftChild() = remove(current.getLeftChild(), data);
} else if (current.getData().compareTo(data) < 0) {
current.getRightChild() = remove(current.getRightChild(), data);
} else {
if (current.getLeftChild() == null && current.getRightChild() == null) {
current = null;
} else if (current.getRightChild() == null) {
current = current.getLeftChild();
} else if (current.getLeftChild() == null) {
current = current.getRightChild();
} else {
Nodes<T> temp = findMinFromRight(current.getRightChild());
current.getData() = temp.getData();
current.getRightChild() = remove(current.getRightChild(), temp.getData());
}
}
return current;
}
Er zeigt mir bei folgenden Abschnitten "Variable expected" an, aber hier sollte keine Variable erwartet werden:
if (current.getData().compareTo(data) > 0) {
current.getLeftChild() = remove(current.getLeftChild(), data);
} else if (current.getData().compareTo(data) < 0) {
current.getRightChild() = remove(current.getRightChild(), data);
...
else {
Nodes<T> temp = findMinFromRight(current.getRightChild());
current.getData() = temp.getData();
current.getRightChild() = remove(current.getRightChild(), temp.getData());
}
Danke schonmal für eure Hilfe!