多边净额结算:谁会写二叉树的遍历操作????

来源:百度文库 编辑:高校问答 时间:2024/04/29 22:23:05
要先创建二叉树,然后进行中序遍历
用C语言编写,但是要的是源代码程序,不要算法

template<class elemtype>//二叉树结点
struct nodetype
{
elemtype info;//结点信息
nodetype<elemtype> *llink;//左子树
nodetype<elemtype> *rlink;//右子树
};

template<class elemtype>
void inorder(nodetype<elemtype> *p)//中序遍历
{
if(NULL!=p)
{inorder(p->llink);//使用递归算法先遍历左子树
cout<<p->info<<" ";//访问结点
inorder(p->rlink);//遍历右子树
}
}

找清华数据结构的教材,里面有C语言的树遍历的程序,
三种遍历方式都有。

我会