Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postorder traversal added #219

Merged
merged 22 commits into from May 18, 2021
Merged

Conversation

shivammahajancse
Copy link
Contributor

Have you read the Contributing Guidelines on Pull Requests?

(Yes)

Checklist

  • I've read the contribution guidelines.
  • I've checked the issue list before deciding what to submit.
  • I've edited the README.md and link to my code.

Related Issues or Pull Requests

(#179 )

@vercel
Copy link

vercel bot commented Apr 13, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/neoalgo-docs/neo-algo-docs/DrRPsnaReSg9bQoSBBBav1sAPbPW
✅ Preview: https://neo-algo-docs-git-fork-shivammahajancse-dev5-neoalgo-docs.vercel.app

@shivammahajancse
Copy link
Contributor Author

Please review sir @HarshCasper @atarax665 @ankitaggarwal23 @gat786

@shivammahajancse
Copy link
Contributor Author

Sir @iamrajiv please review

@shivammahajancse
Copy link
Contributor Author

Please review @nidh-ish

@nidh-ish
Copy link
Contributor

@shivammahajancse Make similar changes here as you were asked to do in the in-order and post-order traversal. Run a Grammarly check also.

@shivammahajancse
Copy link
Contributor Author

All changes done @nidh-ish


## Introduction

Binary Tree is a type of tree which have at most two children or we can say at most degree 2. So to traverse the binary tree according to Depth-first search. We have a traversal algorithm called Postorder traversal.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it: A Binary Tree

Binary Tree is a type of tree which have at most two children or we can say at most degree 2. So to traverse the binary tree according to Depth-first search. We have a traversal algorithm called Postorder traversal.

## Explanation
In this type of traversal(Postorder traversal). first, we have to visit left part then right part then its root respectively. In this first visit left part that means we have to traverse the whole left subtree in this order (left->right->root) after that whole right subtree in this order (left->right->root) and then visit root of that subtree. Postorder: (left->right->root).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it:

In this type of traversal(Postorder traversal). first, we have to visit the left part then the right part then its root respectively. In this first visit left part that means we have to traverse the whole left subtree in this order (left->right->root) after that whole right subtree in this order (left->right->root) and then visit the root of that subtree. Postorder: (left->right->root).

Comment on lines 39 to 47
For Postorder traversal, we follow the following algorithm:

* First, we have to traverse the Binary tree in this order(left->right->root).

* Left means traversing the whole left subtree in this order(left->right->root) until we get left child as null.

* Root means parent of that particular subtree.

* Right means traverse the whole right subtree in this (left->right->root) order until we get null.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it: For Postorder traversal, we follow the following algorithm:

First, we have to traverse the Binary tree in this order(left->right->root).

Left means traversing the whole left subtree in this order(left->right->root) until we get the left child as null.

Root means the parent of that particular subtree.

Right means traverse the whole right subtree in this (left->right->root) order until we get null.

#### Output :

```
Postorder traversal : 11 33 22 55 77 66 44
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make stepwise sample input as it asks in the code.

Copy link
Contributor

@iamrajiv iamrajiv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shivammahajancse Resolve the merge conflict.

@shivammahajancse
Copy link
Contributor Author

Sir done @iamrajiv

Copy link
Contributor

@iamrajiv iamrajiv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shivammahajancse Rename this file to postorder_traversal.mdx.

@shivammahajancse
Copy link
Contributor Author

Sir done @iamrajiv

sidebars.js Outdated
@@ -48,7 +48,7 @@ module.exports = {
"data-structures/binary-tree",
"data-structures/Singly-Linked-list",
"data-structures/binary-search-tree",
"data-structures/preorder_traversal"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not delete data-structures/preorder_traversal

docs/data-structures/postorder_traversal.mdx Outdated Show resolved Hide resolved
docs/data-structures/postorder_traversal.mdx Outdated Show resolved Hide resolved
docs/data-structures/postorder_traversal.mdx Outdated Show resolved Hide resolved
docs/data-structures/postorder_traversal.mdx Outdated Show resolved Hide resolved
docs/data-structures/postorder_traversal.mdx Outdated Show resolved Hide resolved
Co-authored-by: Abhinav Anand <manasgmishra@gmail.com>
shivammahajancse and others added 4 commits May 12, 2021 22:34
Co-authored-by: Abhinav Anand <manasgmishra@gmail.com>
Co-authored-by: Abhinav Anand <manasgmishra@gmail.com>
Co-authored-by: Abhinav Anand <manasgmishra@gmail.com>
Co-authored-by: Abhinav Anand <manasgmishra@gmail.com>
@shivammahajancse
Copy link
Contributor Author

Sir all changes done @atarax665

@shivammahajancse
Copy link
Contributor Author

@atarax665 sir please review

Copy link
Contributor

@siddharth25pandey siddharth25pandey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shivammahajancse LGTM 💯 Able to merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants