函数void preorder(bintree t)实现了二叉树的非递归先...
函数void preorder(bintree t)实现了二叉树的非递归先序遍历,该算法借助栈进行实现,请选择合适的选项填入相应的空缺处,使算法完整。 用C语言描述二叉树结点的结构如下: typedef char datatype; /*结点属性值的类型*/ typedef struct node{ /*二叉树结点的类型*/ datatype data; struct node *lchild, *rchild; } bintnode; typedef bintnode *bintree; void preorder (bintree t) { bintree st[100]; //顺序栈 int top=-1; while (t || top!=-1) /*当前处理的子树不为空或栈不为空则循环*/ { if(t) { printf("%c ",t->data); ___(1)_______ //入栈 ___(2)_______ //继续往左子树遍历 } else { ___(3)_______ //取栈顶元,并出栈 t=t->rchild; //继续往右子树遍历 } } }
A、(1) top++;st[top]=t;
B、(1) st[top]=t;top++;
C、(2) t=t->lchild;
D、(2) t->lchild=t->lchild->lchild;
E、(3)t=st[top];top--;
F、(3)top--;t=st[top];