求二叉树的高度/销毁一颗二叉树-->Destroy(Node* root)

来源:互联网 发布:spss mac 教程 编辑:程序博客网 时间:2024/05/11 23:23
int  HeightOfBinatyTree1(BinaryTreeNode* pRoot) //二叉树的高度{    if (pRoot == NULL)        return 0;    int m = HeightOfBinatyTree1(pRoot->_pLeft);    int n = HeightOfBinatyTree1(pRoot->_pRight);    return (m>n)? (m+1):(n+1);}void Destory(BinaryTreeNode*& pRoot)//销毁二叉树{    if (pRoot == NULL)        return ;    if (pRoot->_pLeft)        Destory(pRoot->_pLeft);    if (pRoot->_pRight)        Destory(pRoot->_pRight);    delete(pRoot);    pRoot = NULL;}
原创粉丝点击