[二叉树专题]:递归求解二叉树的全部节点数目

递归求解二叉树的全部节点数目



template<typename elemType> 
int BinaryTree<elemType>::nodeCount(nodeType<elemType>*p) 
{ 
    if(p == NULL) 
    { 
        return 0; 
    } 
    else 
    { 
        return 1 + nodeCount(p->llink) +nodeCount(p->rlink); 
    } 
} 



你可能感兴趣的:(递归,二叉树,笔试面试)