45_平衡排序树(AVL树)

  1. 递归调用本质上是栈结构,调试把栈打开,理解清楚递归代码逻辑。
  2. 中缀表达式中序遍历,后序表达式计算
  3. 查找递归
  4. 删除叶子结点直接删除,删除节点只有一个孩子,把删除节点的孩子设为删除节点

删除根结点,把右边最小的替换过去获得左边最大的

右边最小:只有一个孩子或者最小

  1. 排序树缺点,一直插入有序数会变成链表

平衡排序树

  1. 任意一个结点的左子树的高度减去右子树的高度小于等于一
  2. 树的高度膨胀的时候,通过旋转平衡树的高度
  3. 旋转四种情况
    1. 左边比较重
      1. 左边不平衡:右单旋转
      2. 右边不平衡:左单旋转
    2. 右边比较重
      1. 左边不平衡:右单旋转
      2. 右边不平衡:左单旋转
    3. 先左转再右转:左双旋转
    4. 先右转再左转:右双旋转

作业

1.非递归实现AVL树

 //Stack.h
#pragma once

template 
class CStack
{
private:
    class CLinkNode     //单向链表
    {
    public:
        CLinkNode()
        {
            m_pElement = nullptr;
            m_pNextNode = nullptr;
        }

        CLinkNode(const T& element)
        {
            m_pElement = new T(element);
            m_pNextNode = nullptr;
        }

        ~CLinkNode()
        {
            if (m_pElement != nullptr)
            {
                delete m_pElement;
            }
        }

    public:
        T* m_pElement;              //元素
        CLinkNode *m_pNextNode;     //下一个结点
    };

public:
    CStack()
    {
        m_pStackTop = nullptr;
        setSize(0U);
    }

    CStack(const T& element)
    {
        m_pStackTop = new CLinkNode(element);
        setSize(1U);
    }

    ~CStack()
    {
        while (m_pStackTop != nullptr)
        {
            pop();
        }
    }

    void push(const T& element)                 //压栈
    {
        CLinkNode *pNode = new CLinkNode(element);
        pNode->m_pNextNode = m_pStackTop;
        m_pStackTop = pNode;
        setSize(getSize() + 1U);
    }

    void pop()                                //出栈
    {
        if (getSize() > 0)
        {
            CLinkNode *pOldNode = m_pStackTop;
            m_pStackTop = pOldNode->m_pNextNode;
            delete pOldNode;
            setSize(getSize() - 1U);
        }
    }

    T* getTop() const    //获得栈顶元素
    {
        return m_pStackTop->m_pElement;
    }

    const unsigned getSize() const  //获得栈的大小
    {
        return m_uSize;
    }

private:
    void setSize(const unsigned size)   //设置栈大小
    {
        m_uSize = size;
    }

private:
    CLinkNode *m_pStackTop;     //栈顶
    unsigned m_uSize;           //栈的大小
};
 //Queue.h
#pragma once

template 
class CQueue
{
private:
    class CLinkNode     //单向链表
    {
    public:
        CLinkNode()
        {
            m_pElement = nullptr;
            m_pNextNode = nullptr;
        }

        CLinkNode(const T& element)
        {
            m_pElement = new T(element);
            m_pNextNode = nullptr;
        }

        ~CLinkNode()
        {
            if (m_pElement != nullptr)
            {
                delete m_pElement;
            }
        }

    public:
        T* m_pElement;              //元素
        CLinkNode *m_pNextNode;     //下一个结点
    };

public:
    CQueue()
    {
        m_pQueueHead = nullptr;
        m_pQueueTail = nullptr;
        setSize(0U);
    }

    CQueue(const T& element)
    {
        CLinkNode *pNode = new CLinkNode(element);
        m_pQueueHead = m_pQueueTail = pNode;
        setSize(1U);
    }

    ~CQueue()
    {
        while (getSize() > 0U)
        {
            pop();
        }
    }

    void push(const T& element)                 //入队
    {
        if (getSize() == 0U)
        {
            CLinkNode *pNode = new CLinkNode(element);
            m_pQueueHead = m_pQueueTail = pNode;
            setSize(1U);
        }
        else
        {
            CLinkNode *pNode = new CLinkNode(element);
            m_pQueueTail->m_pNextNode = pNode;
            m_pQueueTail = pNode;
            setSize(getSize() + 1U);
        }
    }

    void pop()                                //出队
    {
        if (getSize() == 0U)
        {
            return;
        }
        else
        {
            CLinkNode *pNode = m_pQueueHead;
            m_pQueueHead = pNode->m_pNextNode;
            delete pNode;
            setSize(getSize() - 1U);
        }
    }

    T* getTail() const    //获得队列尾部元素
    {
        if (getSize() > 0)
        {
            return m_pQueueTail->m_pElement;
        }
        else
        {
            throw 0;
        }
    }

    T* getHead() const  //获得队列头部元素
    {
        if (getSize() > 0)
        {
            return m_pQueueHead->m_pElement;
        }
        else
        {
            throw 0;
        }
    }

    const unsigned getSize() const  //获得队列的大小
    {
        return m_uSize;
    }

private:
    void setSize(const unsigned size)   //设置队列大小
    {
        m_uSize = size;
    }

private:
    CLinkNode *m_pQueueHead;    //队列头
    CLinkNode *m_pQueueTail;     //队列尾
    unsigned m_uSize;           //队列的大小
};
 //BInaryTree.h
#pragma once
#include "Stack.h"
#include "Queue.h"
#include 
using namespace std;

template 
class CBinaryTree
{
private:
    class TreeNode
    {
    public:

        TreeNode(const T &element,
            TreeNode *left = nullptr,
            TreeNode *right = nullptr,
            int ef = 0
        )
        {
            m_pElement = new T(element);
            m_pLeft = left;
            m_pRight = right;
            m_iEf = ef;
        }

    public:
        T *m_pElement;          //元素
        TreeNode *m_pLeft;      //左儿子
        TreeNode *m_pRight;     //右儿子
        int m_iEf;              //平衡因子
    };

public:
    CBinaryTree()
    {
        m_pTreeRoot = nullptr;
    }

    CBinaryTree(const T& element)
    {
        m_pTreeRoot = new TreeNode(element);
    }

    ~CBinaryTree()
    {
        //removeTree(m_pTreeRoot);
        removeTree_n(m_pTreeRoot);
    }

    CBinaryTree& insert_n(const T& element)     //非递归增加
    {
        if (empty())   //如果根节点为空,表示为第一个节点
        {
            m_pTreeRoot = new TreeNode(element);
            balance(m_pTreeRoot);         //平衡树
            return *this;
        }

        CStack stack;
        TreeNode *pNode = m_pTreeRoot;
        TreeNode *pLastNode = nullptr;

        //压栈之前的结点位置
        while (pNode != nullptr)
        {
            //判断大小来确定放左孩子还是右孩子
            if (element > *pNode->m_pElement)
            {
                stack.push(pNode);
                pNode = pNode->m_pRight;
            }
            else if (element < *pNode->m_pElement)
            {
                stack.push(pNode);
                pNode = pNode->m_pLeft;
            }
        }
        //存放新结点
        pNode = *stack.getTop();

        if (element > *pNode->m_pElement)
        {
            pNode->m_pRight = new TreeNode(element);
            balance(pNode->m_pRight);
        }
        else if (element < *pNode->m_pElement)
        {
            pNode->m_pLeft = new TreeNode(element);
            balance(pNode->m_pLeft);
        }
            
        //平衡树高度
        while (stack.getSize() != 0U)
        {
            pNode = *stack.getTop();
            pLastNode = pNode;
            balance(pNode); //第5次增加到3的时候
            if (pLastNode != pNode && *stack.getTop() != m_pTreeRoot)
            {
                if (*pNode->m_pElement > *pLastNode->m_pElement)
                {
                    pLastNode = pNode;
                    stack.pop();
                    pNode = *stack.getTop();
                    pNode->m_pRight = pLastNode;
                }
                else if (*pNode->m_pElement < *pLastNode->m_pElement)
                {
                    pLastNode = pNode;
                    stack.pop();
                    pNode = *stack.getTop();
                    pNode->m_pLeft = pLastNode;
                }
            }
            else
            {
                stack.pop();
            }
        }
        if (m_pTreeRoot != pNode)
        {
            m_pTreeRoot = pNode;
        }

        return *this;
    }

    void remove_n(const T& element) //非递归删除
    {
        if (!empty())
        {
            CStack stack;
            TreeNode *pNode = m_pTreeRoot;

            while (true)    //寻找结点
            {
                if (pNode != nullptr)
                {
                    if (element > *pNode->m_pElement)
                    {
                        stack.push(pNode);
                        pNode = pNode->m_pRight;
                    }
                    else if (element < *pNode->m_pElement)
                    {
                        stack.push(pNode);
                        pNode = pNode->m_pLeft;
                    }
                    else if (element == *pNode->m_pElement)
                    {
                        break;
                    }
                }
                else
                {
                    stack.~CStack();
                    return;
                }
            }

            //如果找到了结点
            if (!(  stack.getSize() == 0U
                    && pNode->m_pLeft == nullptr
                    && pNode->m_pRight == nullptr)
                )
            {
                if (pNode->m_pLeft == nullptr
                    && pNode->m_pRight == nullptr) //如果为叶子节点
                {
                    TreeNode *pParmarNode = *stack.getTop();
                    if (pParmarNode->m_pRight == pNode)
                    {
                        delete pParmarNode->m_pRight;
                        pParmarNode->m_pRight = nullptr;
                    }
                    else
                    {
                        delete pParmarNode->m_pLeft;
                        pParmarNode->m_pLeft = nullptr;
                    }
                    balance(pParmarNode);
                    stack.pop();

                    while (stack.getSize() != 0U)
                    {
                        pParmarNode = *stack.getTop();
                        stack.pop();
                        balance(pParmarNode);
                    }

                    if (m_pTreeRoot != pParmarNode)
                    {
                        m_pTreeRoot = pParmarNode;
                    }

                    return;
                }
                else if (pNode->m_pLeft == nullptr  //一个孩子
                            ||
                         pNode->m_pRight == nullptr
                        )
                {
                    if (stack.getSize() != 0U)
                    {
                        TreeNode *pOld = pNode; //保留删除点位置
                        TreeNode *pParmarNode = *stack.getTop();  //获取父节点指针

                        pNode = (pNode->m_pLeft != nullptr)
                            ? pNode->m_pLeft
                            : pNode->m_pRight;  //删除节点的非空节点

                        if (pParmarNode->m_pLeft == pOld)   //设父节点的原位置为删除节点的左或者右节点
                        {
                            pParmarNode->m_pLeft = pNode;
                        }
                        else
                        {
                            pParmarNode->m_pRight = pNode;
                        }

                        delete pOld;
                        stack.pop();
                        balance(pNode);
                        balance(pParmarNode);

                        while (stack.getSize() != 0U)
                        {
                            pParmarNode = *stack.getTop();
                            stack.pop();
                            balance(pParmarNode);
                        }

                        if (m_pTreeRoot != pParmarNode)
                        {
                            m_pTreeRoot = pParmarNode;
                        }

                        return;
                    }
                    else                        //删除的是树根的左树或者右树
                    {
                        if (m_pTreeRoot->m_pLeft != nullptr)
                        {
                            m_pTreeRoot = m_pTreeRoot->m_pLeft;
                            delete pNode;
                        }
                        else
                        {
                            m_pTreeRoot = m_pTreeRoot->m_pRight;
                            delete pNode;
                        }

                        return;
                    }
                }
                else                               //二个孩子,删除节点左子树的最右侧节点,它的值代替当前节点
                {
                    if (stack.getSize() != 0U)
                    {
                        TreeNode *pParmarNode = pNode->m_pLeft;
                        TreeNode *pElementNode = pNode->m_pLeft;

                        while (true)
                        {
                            if (pElementNode->m_pRight == nullptr)
                            {
                                break;
                            }

                            pElementNode = pElementNode->m_pRight;
                        }

                        *pNode->m_pElement = *pElementNode->m_pElement; //修改值

                        if (pParmarNode == pElementNode)
                        {
                            pNode->m_pLeft = nullptr;
                        }
                        else
                        {
                            while (true)                                    //删除
                            {
                                if (pParmarNode->m_pRight == pElementNode)
                                {
                                    break;
                                }
                                pParmarNode = pParmarNode->m_pRight;
                            }
                            pParmarNode->m_pRight = nullptr;
                        }

                        delete pElementNode;
                        balance(pNode);

                        while (stack.getSize() != 0U)
                        {
                            pNode = *stack.getTop();
                            stack.pop();
                            balance(pNode);
                        }

                        if (m_pTreeRoot != pNode)
                        {
                            m_pTreeRoot = pNode;
                        }

                        return;
                    }
                    else                //如果为三个节点的二叉树
                    {
                        m_pTreeRoot = pNode->m_pRight;
                        pNode->m_pRight->m_pLeft = pNode->m_pLeft;
                        balance(m_pTreeRoot);
                        delete pNode;
                        return;
                    }
                }
            }
            else              //如果栈大小为0切左右结点为空表示树只有一个结点切为栈顶
            {
                m_pTreeRoot = nullptr;
                delete pNode;
            }

        }
        /*
        //两个孩子
        else
        {
            //找到右边最小
            node->m_pElement = findMin(node->m_pRight)->m_pElement;
            remove(*node->m_pElement, node->m_pRight);
        }

        //平衡
        balance(node);
        */
    }

    bool find_n(const T& element) //非递归查找
    {
        if (!empty()) //如果空树返回false
        {
            TreeNode *pNode = m_pTreeRoot;
            while (true)
            {
                if (pNode != nullptr)
                {
                    if (element > *pNode->m_pElement)
                    {
                        pNode = pNode->m_pRight;
                    }
                    else if (element < *pNode->m_pElement)
                    {
                        pNode = pNode->m_pLeft;
                    }
                    else
                    {
                        return true;
                    }
                }
                else
                {
                    return false;
                }
            }
            
        }
        else
        {
            return false;
        }
    }

    CBinaryTree& insert(const T& element)       //增加结点
    {
        insert(element, m_pTreeRoot);
        return *this;
    }

    void remove(const T& element)
    {
        remove(element, m_pTreeRoot);
        return;
    }

    bool find(const T& element)
    {
        return find(element, getRoot());
    }

    bool empty()
    {
        if (m_pTreeRoot == nullptr)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    void printTreePre()
    {
        _printTreePre(getRoot());
    }

    void printTreeMid()
    {
        _printTreeMid(getRoot());
    }

    void printTreeAft()
    {
        _printTreeAft(getRoot());
    }

    void printTreeOrd()
    {
        _printTreeOrd(getRoot());
    }

private:

    void removeTree(TreeNode* node)
    {
        if (node != nullptr)
        {
            removeTree(node->m_pLeft);
            removeTree(node->m_pRight);
            delete node;
        }
    }

    void removeTree_n(TreeNode* node)
    {
        if (!empty())
        {
            int i = 0;
            CStackstack;
            TreeNode *curNode = m_pTreeRoot;
            TreeNode *topNode = nullptr;
            TreeNode *lastNode = nullptr;

            while (curNode != nullptr
                ||
                stack.getSize() != 0U
                )
            {
                while (curNode != nullptr)
                {
                    stack.push(curNode);
                    curNode = curNode->m_pLeft;
                }
                //此时curNode指向空节点
                topNode = *stack.getTop();//
                if (topNode->m_pRight == nullptr
                    ||
                    topNode->m_pRight == lastNode)
                {
                    stack.pop();
                    lastNode = topNode;
                    delete topNode;
                    i++;
                }
                else
                {
                    curNode = topNode->m_pRight;
                }
            }

            cout << i << endl;
        }
    }
    
    void remove(const T& element, TreeNode*& node)
    {
        if (node == nullptr)
            return;

        if (element > *node->m_pElement) {
            remove(element, node->m_pRight);
        }
        else if (element < *node->m_pElement) {
            remove(element, node->m_pLeft);
        }
        //是否叶子节点
        else if (node->m_pLeft == nullptr && node->m_pRight == nullptr)
        {
            delete node;
            node = nullptr;
            return;
        }
        //判断一个孩子
        else if (node->m_pLeft == nullptr || node->m_pRight == nullptr)
        {
            TreeNode* old = node;
            node = (node->m_pLeft != nullptr) ? node->m_pLeft : node->m_pRight;
            delete old;
        }
        //两个孩子
        else
        {
            //找到右边最小
            node->m_pElement = findMin(node->m_pRight)->m_pElement;
            remove(*node->m_pElement, node->m_pRight);
        }

        //平衡
        balance(node);
    }

    TreeNode* findMin(TreeNode* node)
    {
        if (node == nullptr)
            return nullptr;

        while (true)
        {
            if (node->m_pLeft == nullptr)
            {
                return node;
            }
            node = node->m_pLeft;
        }
    }

    bool find(const T& element, TreeNode* node)
    {
        if (node != nullptr)
        {
            if (element > *node->m_pElement)
            {
                find(element, node->m_pRight);
            }
            else if (element < *node->m_pElement)
            {
                find(element, node->m_pLeft);
            }
            else if (element == *node->m_pElement)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        else if(node == nullptr)
        {
            return false;
        }
    }

    CBinaryTree& insert(const T& element, TreeNode*& node)
    {
        if (node == nullptr)
        {
            node = new TreeNode(element);
        }
        else if (*node->m_pElement > element)
        {
            insert(element, node->m_pLeft);
        }
        else if (*node->m_pElement < element)
        {
            insert(element, node->m_pRight);
        }

        balance(node);
        return *this;
    }

    int getEf(TreeNode *node)    //获取左右子树平衡因子最大值
    {
        if (node == nullptr)
        {
            return 0;
        }
        else
        {
            return node->m_iEf;
        }
    }

    TreeNode* getRoot()
    {
        return m_pTreeRoot;
    }

    int getMax(int value1, int value2)
    {
        return value1 > value2 ? value1 : value2;
    }

    void rotateRight(TreeNode*& node)   //右旋转
    {
        /*
                k1
            k2
        k3
        */
        /*
               10
            5     12
          3  7
        4

            5
           3  10
          4  7  12
        */

        TreeNode *K1 = node;
        TreeNode *K2 = K1->m_pLeft;
        TreeNode *A = K2->m_pLeft;
        TreeNode *B = K2->m_pRight;
        TreeNode *C = K1->m_pRight;

        K1->m_pLeft = B;
        K2->m_pRight = K1;

        K1->m_iEf = getMax(getEf(B), getEf(C)) + 1;
        K2->m_iEf = getMax(getEf(K1), getEf(A)) + 1;

        node = K2;

    }

    void rotateLeft(TreeNode*& node) //左单旋转
    {
        /*
                5
              4    10
                  9  11
                       12
                10
               5  11
             4  9   12
        */
        TreeNode *K1 = node;
        TreeNode *K2 = K1->m_pRight;
        TreeNode *A = K1->m_pLeft;
        TreeNode *B = K2->m_pLeft;
        TreeNode *C = K2->m_pRight;

        K1->m_pRight = B;
        K2->m_pLeft = K1;

        K1->m_iEf = getMax(getEf(A), getEf(B)) + 1;
        K2->m_iEf = getMax(getEf(K1), getEf(C)) + 1;

        node = K2;
    }

    void rotateLeftRight(TreeNode*& node)   //先左后右
    {
        rotateLeft(node->m_pLeft);
        rotateRight(node);
    }

    void rotateRightLeft(TreeNode*& node)   //先右后左
    {
        rotateRight(node->m_pRight);
        rotateLeft(node);
    }

    void balance(TreeNode*& node) //平衡二叉树
    {
        //设置高度
        if (getEf(node->m_pLeft) > getEf(node->m_pRight))
        {
            node->m_iEf = getEf(node->m_pLeft) + 1;
        }
        else
        {
            node->m_iEf = getEf(node->m_pRight) + 1;
        }
        //判断平衡
        if (getEf(node->m_pLeft) - getEf(node->m_pRight) > 1)
        {
            //左边不平衡
            if (getEf(node->m_pLeft->m_pLeft) - getEf(node->m_pLeft->m_pRight) > 0)
            {
                rotateRight(node);
            }
            else
            {
                //左双旋转
                rotateLeftRight(node);
            }
        }
        else if (getEf(node->m_pLeft) - getEf(node->m_pRight) < -1)
        {
            //右边不平衡
            if (getEf(node->m_pRight->m_pLeft) - getEf(node->m_pRight->m_pRight) < 0)
            {
                //左单旋转
                rotateLeft(node);
            }
            else
            {
                //右双旋转
                rotateRightLeft(node);
            }
        }

    }

    void _printTreePre(TreeNode *node)             //前序遍历
    {
        if (!empty())
        {
            /*
            if (node != nullptr)
            {
            cout << *(node->m_pElement) << " ";
            printTreePre(node->m_pLeft);
            printTreePre(node->m_pRight);
            }
            */
            //压栈当前根,打印当前根元素,根等于当前更的左孩子,当当前更的左孩子为空时出栈,并进去当前根的右孩子,压栈右孩子。循环
            CStack stack;
            while (true)
            {
                if (node != nullptr)
                {
                    stack.push(node);
                    cout << *node->m_pElement << " ";
                    node = node->m_pLeft;
                }
                else if (node == nullptr && stack.getSize() == 0U)
                {
                    break;
                }
                else if (node == nullptr)
                {
                    node = *stack.getTop();
                    stack.pop();
                    node = node->m_pRight;
                }
            }
            cout << endl;

        }
    }

    void _printTreeMid(TreeNode *node)             //中序遍历
    {
        if (!empty())
        {
            /*
            if (node != nullptr)
            {
            printTreeMid(node->m_pLeft);
            cout << *(node->m_pElement) << " ";
            printTreeMid(node->m_pRight);
            }
            */
            //压栈当前根,根等于当前更的左孩子,当当前更的左孩子为空时出栈,打印当前根元素,并进去当前根的右孩子,压栈右孩子。循环
            CStack stack;
            while (true)
            {
                if (node != nullptr)
                {
                    stack.push(node);
                    node = node->m_pLeft;
                }
                else if (node == nullptr && stack.getSize() == 0U)
                {
                    break;
                }
                else if (node == nullptr)
                {
                    node = *stack.getTop();
                    stack.pop();
                    cout << *node->m_pElement << " ";
                    node = node->m_pRight;
                }
            }
            cout << endl;
        }
    }

    void _printTreeAft(TreeNode *node)             //后序遍历
    {
        if (!empty())
        {
            /*
            if (node != nullptr)
            {
            printTreeAft(node->m_pLeft);
            printTreeAft(node->m_pRight);
            cout << *(node->m_pElement) << " ";
            }
            */

            //当左孩子不为空一直压栈当前结点,为空当前结点就为栈顶元素,出栈,当前结点为节点右孩子,如果结点不为空压栈右孩子,打印。
            //后序:2 5 7 6 4 17 21 20 10

            CStackstack;
            TreeNode *curNode = m_pTreeRoot;
            TreeNode *topNode = nullptr;
            TreeNode *lastNode = nullptr;
            while (curNode != nullptr
                    || 
                   stack.getSize() != 0U
                )
            {
                while (curNode != nullptr)
                {
                    stack.push(curNode);
                    curNode = curNode->m_pLeft;
                }
                //此时curNode指向空节点
                topNode = *stack.getTop();//
                if (topNode->m_pRight == nullptr
                    ||
                    topNode->m_pRight == lastNode)
                {
                    stack.pop();
                    cout << *topNode->m_pElement << " ";
                    lastNode = topNode;
                }
                else
                {
                    curNode = topNode->m_pRight;
                }
            }
            cout << endl;
            
        }
        
    }

    void _printTreeOrd(TreeNode *node)             //层序遍历
    {
        //10 4 20 2 6 17 21 5 7
        if (!empty())
        {
            CQueue queue;
            TreeNode *pLeft = nullptr;
            TreeNode *pRight = nullptr;
            queue.push(node);

            while (queue.getSize() != 0U)
            {
                node = *queue.getHead();
                cout << *node->m_pElement << " ";
                pLeft = node->m_pLeft;
                pRight = node->m_pRight;
                if (pLeft != nullptr)
                {
                    queue.push(pLeft);
                }
                if (pRight != nullptr)
                {
                    queue.push(pRight);
                }
                queue.pop();
            }
            cout << endl;

        }
    }

private:
    TreeNode *m_pTreeRoot;  //树根
};
 //test.cpp
#include "BInaryTree.h"

int main()
{
    {
        CBinaryTree tree;

        for (int i = 0; i < 400; i++)
        {
            tree.insert_n(i);
        }
        
        /*
        删除
        
        tree.remove(10);
        tree.remove(11);
        */
        //tree.printTreeMid();
        //tree.printTreeAft();


        //bool a = tree.find_n(6);
        //tree.remove_n(38);
        //tree.printTreeAft();
        //tree.printTreeMid();
        //tree.printTreeOrd();
    }

    system("pause");
    return 0;
}
0 条评论
发表一条评论