Java Program to calculate the Difference between the Sum of the Odd Level and the Even Level Nodes of a Binary Tree
In this program, we need to calculate the difference between the sum of nodes present at odd levels and sum of nodes present at even levels. Suppose, if a tree contains 5 levels, then
In the above diagram, odd levels are represented using blue dotted lines and even with green.
a. The difference() will calculate the difference between the sum of nodes at the odd and even levels:
Difference between sum of odd level and even level nodes: 11