Code:- Recursive Approach class Solution { public: // Helper function to perform post-order traversal void postOrder(Node *root, vector& res) { if (!root) return; // Base case: if root is null, return for (auto child : root->children) postOrder(child, res); // Recurse on children res.push_back(root->val); // Add current node's value to result } // Main function to initiate post-order traversal vector postorder(Node* root) { vector res; // Result vector to store the traversal postOrder(root, res); // Call helper function return res; // Return the result } }; Iterative Approach class Solution { public: vector postorder(Node* root) { if (!root) return {}; // Return empty vector if root is null stack stk; // Stack to manage nodes stk.push(root); // Push root node to stack vector res; // Vector to store post-order traversal while (!stk.empty()) { auto curr = stk.top(); // Get the current node stk.pop(); // Remove node from stack for (auto child : curr->children) stk.push(child); // Push children to stack res.push_back(curr->val); // Add current node's value to result } reverse(res.begin(), res.end()); // Reverse to get post-order return res; // Return result } };