这个很容易想到
层次遍历是自上而下,从左到右,
说明将层次遍历出队列的元素入栈,最后出栈即可得
b本篇以根节点为8的二叉搜索树8、5、10、3、7、9、11为例
typedef struct Tree {
int Data;
struct Tree *Lc;
struct Tree *Rc;
}Btree; //树节点
typedef struct Node {
Btree *P1;
struct Node *rear;
}Nodes; //栈
typedef struct Q {
Btree *P3;
struct Q*next;
}Array; //队列
Btree *insert(Btree*Ntree, int a);//插入节点
void Push(Node**top, Btree*P2); //压入栈
void Pop(Node**top); //出栈
void Push2(Array**q, Btree*P); //入队列
void Pop2(Array**head); //出队列
void BLorder(Btree* Ntree) ; //如题遍历
int main() {
int a;
Btree *Ntree;
Ntree = (Btree*)malloc(sizeof