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

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 }

你可能感兴趣的:(二叉树)