在中序线索二叉树上寻找结点p的中序前驱结点的算法如下: Threadnode *InPreNode(Threadnode * p) {/*在中序线索二叉树上寻找结点p的中序前驱结点 */ Threadnode * pre; pre=p-lchild; if (p-ltag!=1) while (pre-rtag==0) pre=pre-rchild; return(pre); } 在中序线索二叉树上寻找结点p的中序后继结点的算法如下: Threadnode *InPostNode(Threadnode * p) {/* 在中序线索二叉树上寻找结点p的中序后继结点 */ Threadnode * post; post=p-rchild; if (p-rtag= =0) while (post-ltag==0) post=post-lchild; return (post); } 5.在中序线索二叉树上查找值为x的结点(带头结点) BiThrTree Search(BiThrTree head,datatype x) {BiThrTree p=head-lchild; if(p==head)return NULL; 找到中序遍历的第一个结点; 从该结点开始顺着后
原创力文档

文档评论(0)