Input : Tree
1 / \ 2 3 / / \ 4 5 6 / \ / / 7 8 9 10 / / \ 11 12 13
Output :52
Explanation: Total items we can take for Odd levels are: {2, 3, 7, 8, 9, 10} = 39
Total items we can take for Odd levels are:{1, 4, 5, 6, 11, 12, 13} = 52
Therefor Odd Level < Even Level
Max sum is = 52.
Program :
Comments