线索二叉树 //二叉树的二叉线索存储表示 typedef enum PointerTag{linkThread}; typedef Struc BithrNode{ TelemType data; struct Bithrnode *lchild *rchild; PointerTag Ltag Rtag; }BiThrNode *BiThrTree; Status InOrderTraverse_Thr(BiThrTree t Status(*visit)(TelemType e)){ //T p=Tlchild; while(p!=t){ while(p>Ltag==Link) p=p>lchild; if(!Visit(p>Rtag==Thread&&p>rchild!T){ while(p>Rtag==Thread&&p>rchild!=T){ p=p>rchild; visit(p>data); } p=p>rchild; }return ok; }//InOrderTraverse_Thr Status InOrderThreading(BiThrTree &ThrtBithrTree t){ //中序遍历二叉树T并将其中序线索化Thrt指向头结点 If(!(Thrt=(BiThrTree)malloc(sizeof(BiThrNode)))) exit(OVERFLOW); Thrt>Ltag=Link; Thrt>Rtag=Thead; Thrt>rchild=Thrt; If(!T)Thrt>lchild=Thrt; InThreading(T; Pre>lchild=T; pre=Thrt; Thrt>rchild=pre; } return ok; }//InOrderThreading 返回《数据结构》考研复习精编 [] [] [] [] [] [] [] [] [] [] |