Zig Zag Traversal of Binary Tree

In this article, we present 4 different approaches for Zig Zag Traversal of Binary Tree. The zigzag traversal of the binary tree can be better understood using below example:
folded-2
For the above tree, the zigzag traversal will be : 1 2 5 6 7 3 4

There are many approaches for this problem like:

We can use two stacks and swap the values of these stacks at each level.We can use deque to solve problem. Depending upon the even or odd level we will push or pop.We can also use recursion. It will print th...
 •  0 comments  •  flag
Share on Twitter
Published on April 12, 2021 09:34
No comments have been added yet.