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.
Maximum spiral sum = 4 + (-1) + (-2) + 1 + 5 = 7
Maximum Spiral Sum = 7
Time Complexity: O(n).
Auxiliary Space: O(n).
- Clockwise Spiral Traversal of Binary Tree | Set - 2
- Clockwise Spiral Traversal of Binary Tree
- Reverse Clockwise spiral traversal of a binary tree
- Anti Clockwise spiral traversal of a binary tree
- Reverse Anti Clockwise Spiral Traversal of a Binary Tree
- Convert a Binary Tree into Doubly Linked List in spiral fashion
- Maximum sub-tree sum in a Binary Tree such that the sub-tree is also a BST
- Maximum Path Sum in a Binary Tree
- Maximum width of a binary tree
- Find maximum level sum in Binary Tree
- Sum of nodes at maximum depth of a Binary Tree | Set 2
- Find maximum among all right nodes in Binary Tree
- Get maximum left node in binary tree
- Maximum sum of nodes in Binary tree such that no two are adjacent
- Maximum parent children sum in Binary tree
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.