X283: Binary Tree Sum Nodes Exercise
Write a recursive function int BTsumall(BinNode root)
that
returns the sum of the values for all of the nodes of the
binary tree with root root
.
Here are methods that you can use on the BinNode
objects:
AخA
1
interface BinNode {
2
public int value();
3
public void setValue(int v);
4
public BinNode left();
5
public BinNode right();
6
public boolean isLeaf();
7
}
Write the BTsumall
function below:
Your Answer:
Feedback
Your feedback will appear here when you check your answer.