求二叉树节点总数

 

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

 

 

 

EOF

转载于:https://www.cnblogs.com/lihaozy/archive/2012/12/07/2807178.html

你可能感兴趣的:(数据结构与算法,c/c++)