不知道不用栈和递归是否可以实现树的线索化,昨天想了一晚上也没头绪。呵呵,我是自学计算机的,是有点菜。
用递归实现线索化我觉得还是用了栈。按书上说法是递归栈。
晕~~~~~~~~
递归实现中序线索化
inthread(current,pre)
{
if (current!=null)
inthread(current->leftchild;pre)//这里,如果不是递归(栈),怎么记住当前结
if (current->lefttag=0) 点?
{
current->leftchild=pre;
current->lefttag=1;
}
if (pre->righttag=0)
{
pre->rightchild=current;
pre->righttag=1;
}
pre=current;
inthread(current->rightchild,pre)//这里也一样啊。有非递归和不用栈的发方法吗?
}