C++ || Easy to understand || Recursive Solution
Recursive Solution for N-ary Tree Post Order Traversal\n\nPost order traversal says that : \n\nFor Binary Tree it is : Traverse Left, Right and then the Root \n
Recursive Solution for N-ary Tree Post Order Traversal\n\n**Post order traversal says that :** \n\nFor **Binary Tree** it is : Traverse Left, Right and then the Root \nHere, traverse the children first from the left then the root or parent.\n\n**Step 1:** Simply create a **vector of post** to store the traversed elements.\n**Step 2:** Calling the function **traverse(root,post)** for the postorder traversal\n**Step 3:** Go into the traverse function check whether root is null or not, if yes then return;     otherwise\n\t\t\t\trun a loop for traversing all the children of the root node and recursively call the function traverse till the                children becomes null (traverse from the left nodes) \n**Step 4:** Push the elements into the post.\n**Step 5:** Return the post from postorder function;\n\t\t\t\t\n```\nclass Solution {\npublic:\n    void traverse(Node*root,vector<int> &post){\n        if(root==NULL)  return;\n        for(auto x:root->children){\n            traverse(x,post);\n        }\n        post.push_back(root->val);\n    }\n    vector<int> postorder(Node* root) {\n        vector<int> post;\n        traverse(root,post);\n        return post;\n    }\n};\n```\n\nIf you liked this post, kindly upvote : )
['Recursion', 'C', 'C++']