1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
|
public int countChilds() {
return countChildsRecurs() - 1; //es sollen nur die Nachfolger gezählt werden, also den Knoten selbst wieder abziehen
}
private int countChildsRecurs() {
int result = 1; //der aktuelle Knoten
if (left != null) result += left.countChildsRecurs();
if (right != null) result += right.countChildsRecurs();
return result;
} |