[C] 建立中序线索二叉树 →→→→→进入此内容的聊天室

来自 , 2019-04-16, 写在 C, 查看 166 次.
URL http://www.code666.cn/view/24f0d2c9
  1. int InOrderThr ( BiThrTree *head,BiThrTree T )
  2. {/*中序遍历二叉树T,并将其中序线索化,*head 指向头结点。*/
  3.         if ( ! ( *head = ( BiThrNodeType* ) malloc ( sizeof ( BiThrNodeType ) ) ) ) return 0;
  4.         ( *head )->ltag=0;
  5.         ( *head )->rtag=1; /*建立头结点*/
  6.         ( *head )->rchild=*head; /*右指针回指*/
  7.         if ( !T ) ( *head )->lchild =*head; /*若二叉树为空,则左指针回指*/
  8.         else
  9.         {
  10.                 ( *head )->lchild=T;
  11.                 pre= head;
  12.                 InThreading ( T ); /*中序遍历进行中序线索化*/
  13.                 pre->rchild=*head;
  14.                 pre->rtag=1; /*最后一个结点线索化*/
  15.                 ( *head )->rchild=pre;
  16.         }
  17.         return 1;
  18. }
  19.  
  20.  

回复 "建立中序线索二叉树"

这儿你可以回复上面这条便签

captcha