标签:blog os io for ar div amp log
二叉树的后序遍历
递归实现
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: void PostOrder(TreeNode* root,vector<int>&vec) { if(root!=NULL) { PostOrder(root->left,vec); PostOrder(root->right,vec); vec.push_back(root->val); } } vector<int> postorderTraversal(TreeNode *root) { vector<int>vec; PostOrder(root,vec); return vec; } };
Binary Tree Postorder Traversal,布布扣,bubuko.com
Binary Tree Postorder Traversal
标签:blog os io for ar div amp log
原文地址:http://www.cnblogs.com/zsboy/p/3880087.html