数据结构PPt——2.pptx

数据结构PPt——2

二叉树的抽象数据类型;6.4 二叉树的遍历(Traversing);;中序遍历算法框架:;后序遍历算法框架:; //采用二叉链表存储结构 status POT ( BiTree T, Status (* Visit)(TElemType e)) { if (T) { // 二叉树不为空 Visit(T - data);// 访问根结点 POT ( T-lchild, Visit ); //先序遍历左子树 POT ( T-rchild, Visit ); //先序遍历右子树 return OK; } } //POT;//最简单的Visit 函数 Status PrintElement ( TElemType e ) { printf(“%d”,root-data); return OK; };status InOT ( BiTree T, Status (* Visit)(TElemType e)) { if (T) { // 二叉树不为空 InOT ( T-lchild, Visit ); //先序遍历左子树 Visit(T - data);//

文档评论(0)

1亿VIP精品文档

相关文档