Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Given a binary tree containing n nodes. The problem is to find the maximum sum obtained when the tree is spirally traversed. In spiral traversal one by one all levels are being traversed with the root level traversed from right to left, then next level from left to right, then further next level from right to left and so on.

                    -2
                    
           -3                  4
             
      5        1         -2        -1
      
 -3                                       2

Maximum spiral sum = 4 + (-1) + (-2) + 1 + 5 = 7