Код: Выделить всё
public int sum() {
return sum(overallRoot);
}
private int sum(IntTreeNode root) {
if (root == null) {
return 0;
} else {
return root.data + sum(root.left) + sum(root.right);
}
}
Следующий код взят из моего основного класса:
Код: Выделить всё
public class TreeClient {
/**
* @param args
*/
public static void main(String[] args) {
IntTree tree = new IntTree(12);
System.out.println(tree.sum());
}
надеюсь, у кого-нибудь будет время ответить!
надеюсь, у кого-то есть время ответить! п>
Подробнее здесь: https://stackoverflow.com/questions/126 ... es-it-stop
Мобильная версия