填空题
[说明]
完成以下中序线索化二叉树的算法。
[函数]
Typedef int datatype;
Typedef struct node {
Int ltag, rtag;
Datatype data;
*lchild,* rchild;
}bithptr;
bithptr pre;
void inthread ( p );
{if
{inthread ( p->lchild );
if ( p->lchild==unll ){{U}} (1) {{/U}};
if ( P->RCHILD=NULL) p->rtag=1;
if{{U}} (2) {{/U}}
{if{{U}} (3) {{/U}}pre->rchild=p;
if ( p->1tag==1 ){{U}} (4) {{/U}};
}
INTHREAD ( P->RCHILD );
{{U}} (5) {{/U}};
}
}
【正确答案】
1、(1) P->LTAG=0 (2) (PRE)
【答案解析】(3) (PRE->RTAG==1) (4) P->LCHILD=PRE (5) PRE=P