Question: Consider the following method: public int xSum ( TreeNode root ) { if root = = null ) return 0 ; return ( ( Integer

Consider the following method:
public int xSum(TreeNode root)
{
if root == null)
return 0 ;
return ((Integer) root.getValue())-
xSum(root.getLeft())+ xSum(root.getRight());
}
}
What value is returned by xSum (root) if root points to the following tree? (Hint: work from the bottom up.)
a ,-9
b ,-10
C 5
d 12
e 20
 Consider the following method: public int xSum(TreeNode root) { if root

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!