数据结构 先序 中序 后序非递归算法(linux c实现)

来源:互联网 发布:网络实名制的弊端 编辑:程序博客网 时间:2024/06/01 07:54

//先序非递归算法
void unpre_order(btree_pnode t)
{
        linklist top;//指向栈顶结点指针
        top =linkstack_create();
        while(t != NULL || !linkstack_empty(top))
        {
                if(t != NULL)
                {
                        printf("%c",t->data);                      
                        if(t->rchild != NULL)
                                linkstack_push(&top,t->rchild);
                        t = t->lchild;
                }
                else
                {
                        t = linkstack_pop(top);
                }
        }

}




阅读全文
0 0