Skip to content
This repository was archived by the owner on Sep 7, 2025. It is now read-only.

zigzag traversal in a binary tree#120

Merged
abranhe merged 1 commit into
AllAlgorithms:masterfrom
SakshiiAgrawal:master
Nov 7, 2020
Merged

zigzag traversal in a binary tree#120
abranhe merged 1 commit into
AllAlgorithms:masterfrom
SakshiiAgrawal:master

Conversation

@SakshiiAgrawal

@SakshiiAgrawal SakshiiAgrawal commented Oct 21, 2020

Copy link
Copy Markdown
Contributor

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...

  • [yes ] New algorithm
  • Update to an algorithm
  • Fix an error
  • Other - Describe below

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 hemanth-kotagiri left a comment

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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 to right. Writing well-documented code is extremely important. Try fixing any other issues of the same kind. Code LGTM.

Copy link
Copy Markdown
Contributor Author

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 abranhe left a comment

Copy link
Copy Markdown
Member

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 to The All ▲lgorithms Project. Without people like you submitting Pull Requests we couldn't run this project. You rock!

@abranhe abranhe merged commit 7f12f2c into AllAlgorithms:master Nov 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants