求二叉树叶子节点的个数

 

int LeavesNodeNum(Node *pRoot)
{
    if (!pRoot)
        return 0;
    if (!pRoot->pLeft && !pRoot->pRight)
        return 1;
    return LeavesNodeNum(pRoot->pLeft) + LeavesNodeNum(pRoot->pRight);
}

 

 

 

 

 

 

EOF

posted on 2012-12-07 16:10  kkmm  阅读(213)  评论(0编辑  收藏  举报