Skip to content

Commit ec4c008

Browse files
committed
13.3
1 parent a76fd11 commit ec4c008

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

13/Aufgabe3/src/Node.java

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class Node {
2+
Node left;
3+
Node right;
4+
int val;
5+
6+
public int sum() {
7+
return (left != null ? left.sum() : 0) + (right != null ? right.sum() : 0) + val;
8+
}
9+
}

13/Aufgabe3/src/Tree.java

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public class Tree {
2+
private Node root;
3+
4+
public int sum() {
5+
return root != null ? root.sum() : 0;
6+
}
7+
}

0 commit comments

Comments
 (0)