砚凉— 发表于 2017-8-14 08:34:41

线索二叉树

本帖最后由 砚凉— 于 2017-8-14 08:34 编辑

存储使用的遍历和读取使用的遍历没有必然联系
中序遍历(递归方法) pre要另外赋初值
void inthreading(bithrtree t)
{
    if(t)
    {
      inthreading(t->lchild);
      if(!t->lchild)//结点部分 t->lchild =0
      {
            t->ltag= thread; //thread=1 ltag为左子树表示
            t->lchild=pre; //足迹保留 此处遍历结束 指向刚遍历的地址(根结点)
      }
      
      if(!t->rchild)
      {
            pre->rtag =thread;//指向下一个地址(上一个根结点)
            pre =t;
      }
      
      pre = t;
      inthreading(t->rchild);
    }
   
}
页: [1]
查看完整版本: 线索二叉树