- Notifications
You must be signed in to change notification settings - Fork174
zigzag traversal in a binary tree#120
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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.
hemanth-kotagiri left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM.
| s2.pop() | ||
| print(temp.data, end = " ") | ||
| # Note that is rightt is appended before left |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Just one small change.rightt toright. Writing well-documented code is extremely important. Try fixing any other issues of the same kind. Code LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
sure, will do it
abranhe left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks so much for your contribution toThe All ▲lgorithms Project. Without people like you submitting Pull Requests we couldn't run this project. You rock!
Uh oh!
There was an error while loading.Please reload this page.
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...