Showing posts with label Traversal. Show all posts
Showing posts with label Traversal. Show all posts

Level order traversal in spiral form

Write a function to print spiral order traversal of a tree.
For below tree, function should print 1, 2, 3, 7, 6, 5, 4.

           [1]
          /   \
       [2]     [3]
      /  \     /  \ 
    [4]  [5] [6]  [7]