主题:请教一道中序线索二叉树题目
在一棵中序线索二叉树中将t插入,作为原结点s的右孩子的算法如下:
Insertrightchild(bitreepointer s,bitreepointer t)
{
t->rightchild=s->rightchild;
t->righttag=s->righttag;
t->leftchild=s;
t-lefttag=1;
if(s->righttag==0)
{
bitreepointer p =s->rightchild;
while(p->lefttag==0)
{
p= 1 ;
if(p->lefttag==1) 2 ;
}
s->rightchild= 3 ;
s->righttag=0;
}
}
我的答案是:1、p->leftchild;
2、p->leftchild=t;
3、t;
各位能帮我看看,我做的对吗?
Insertrightchild(bitreepointer s,bitreepointer t)
{
t->rightchild=s->rightchild;
t->righttag=s->righttag;
t->leftchild=s;
t-lefttag=1;
if(s->righttag==0)
{
bitreepointer p =s->rightchild;
while(p->lefttag==0)
{
p= 1 ;
if(p->lefttag==1) 2 ;
}
s->rightchild= 3 ;
s->righttag=0;
}
}
我的答案是:1、p->leftchild;
2、p->leftchild=t;
3、t;
各位能帮我看看,我做的对吗?