AllAlgorithms / python

Implementation of All ▲lgorithms in Python Programming Language
https://github.com/python
MIT License
346 stars 171 forks source link

zigzag traversal in a binary tree #120

Closed SakshiiAgrawal closed 3 years ago

SakshiiAgrawal commented 3 years ago

The idea is to use two stacks. We can use one stack for printing from left to right and other stack for printing from right to left. In every iteration, we have nodes of one level in one of the stacks. We print the nodes, and push nodes of next level in other stack.

I am creating a pull request for...