2012年11月21日

二叉树的前序、中序、后序遍历的非递归算法及层次遍历算法

摘要: 二叉树的各种非递归遍历中,要数后序比较麻烦了,因为即使左子树为空,也不能马上出栈,而是要判断右子树。以下就给出代码:typedef struct Tnode{ ElemType data; struct Tnode *lchild,*rchild;}BBTnode,*BBTree;typedef struct{ BBTree *base,*top; //栈指针成员 int initsize; //栈初始长度 }Stack;//以下假设已经建好二叉树和栈了status NonFirstView(BBTree T,Stack S) //非递归前序遍历 { while(S.ba... 阅读全文

posted @ 2012-11-21 11:40 Arcfat Tsui 阅读(393) 评论(0) 推荐(0) 编辑

导航