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
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/neoalgo-docs/neo-algo-docs/DrRPsnaReSg9bQoSBBBav1sAPbPW |
Please review sir @HarshCasper @atarax665 @ankitaggarwal23 @gat786 |
Sir @iamrajiv please review |
Please review @nidh-ish |
@shivammahajancse Make similar changes here as you were asked to do in the in-order and post-order traversal. Run a Grammarly check also. |
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. |
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.
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). |
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.
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).
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. |
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.
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 |
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.
Make stepwise sample input as it asks in the code.
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.
@shivammahajancse Resolve the merge conflict.
Sir done @iamrajiv |
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.
@shivammahajancse Rename this file to postorder_traversal.mdx
.
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" |
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.
Do not delete data-structures/preorder_traversal
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>
Co-authored-by: Abhinav Anand <manasgmishra@gmail.com>
Sir all changes done @atarax665 |
@atarax665 sir please review |
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.
@shivammahajancse LGTM 💯 Able to merge
Have you read the Contributing Guidelines on Pull Requests?
(Yes)
Checklist
README.md
and link to my code.Related Issues or Pull Requests
(#179 )