Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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());
- }
- if (root == null) {
- return 0;
- }
- return root.data + sum(root.left) + sum(root.right);
- return root.data + sum(root.left) + sum(root.right);
- return 0;
- if (root == null)
- return 0;
- return root.data + sum(root.left) + sum(root.right);
Add Comment
Please, Sign In to add comment