zoukankan      html  css  js  c++  java
  • 非递归中序遍历二叉树

    void InOrderUnrec(Bitree *t)
    {
        Stack s;
        StackInit(s);
        Bitree *p=t;

        while (p!=NULL || !StackEmpty(s))
        {
            while (p!=NULL)             //遍历左子树
            {
                push(s,p);
                p=p->lchild;
            }
            
            if (!StackEmpty(s))
            {
                p=pop(s);
                visite(p->data);        //访问根结点
                p=p->rchild;            //通过下一次循环实现右子树遍历
            }//endif   
       
        }//endwhile
    }

  • 相关阅读:
    「2019纪中集训Day20」解题报告
    PHP基础入门
    javascript
    正则表达式
    DOM 节点
    对象
    字符串
    函数
    for循环
    jQuery
  • 原文地址:https://www.cnblogs.com/sandy2013/p/3318854.html
Copyright © 2011-2022 走看看