X290: Binary Tree Get Difference Exercise

Given a binary tree, write a recursive function to return the difference between the sum of all node values at odd levels and sum of all node values at even levels. Define the root node to be at level 1.
Here are methods that you can use on the BinNode objects:
   interface BinNode {
      public int value();
      public void setValue(int v);
      public BinNode left();
      public BinNode right();
      public boolean isLeaf();
   }

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.