摘要: TreeNode* flat(TreeNode *root) { if(!root) return NULL; TreeNode *tail1 = flat(root->left); TreeNode *tail2 = flat(root->right); if(tail1) { tail1->right = root->right; tail1->left = NULL; root->right = root->left;... 阅读全文
posted @ 2013-05-29 21:34 summer_zhou 阅读(106) 评论(0) 推荐(0) 编辑
摘要: int _maxDepthH(TreeNode *root,int curDepth) { if(!root) return curDepth; curDepth++; if(!root->left&&!root->right) return curDepth; int d1 = _maxDepthH(root->left,curDepth); int d2 = _maxDepthH(root->right,curDepth); return (d1>d2)?d... 阅读全文
posted @ 2013-05-29 17:55 summer_zhou 阅读(117) 评论(0) 推荐(0) 编辑
摘要: void helper(TreeNode *root,unsigned int curDepth,unsigned int *minDepth) { if(curDepth>=*minDepth-1) return; curDepth++; if(!root->left&&!root->right) { *minDepth = curDepth; return; }else { if(root->left) ... 阅读全文
posted @ 2013-05-29 16:37 summer_zhou 阅读(144) 评论(0) 推荐(0) 编辑