寻找二叉树最小叶子节点值

View Code
 1 //寻找最小叶子节点值
 2 int  minLeaveNode(BinaryTreeNode * root)
 3 {
 4     int lValue, rValue;
 5     if(root->m_pLeft)
 6         lValue = minLeaveNode(root->m_pLeft);
 7     if(root->m_pRight)
 8         rValue = minLeaveNode(root->m_pRight);
 9     if(!root->m_pLeft && !root->m_pRight) 
10         return root->m_nValue;
11     else if(root->m_pLeft && !root->m_pRight)
12         return lValue;
13     else if(!root->m_pLeft && root->m_pRight)
14         return rValue;
15     else return lValue < rValue ? lValue : rValue;
16 }
posted @ 2012-04-21 19:36  可乐爱上了雪碧  阅读(558)  评论(0编辑  收藏  举报