BTNode *CreateBT2(char *post,char *in,int n)
{
BTNode *s;
char r,*p;
int k;
if(n<=0)
return NULL;
r=*(post+n-1);
s=(BTNode *)malloc(sizeof(BTNode));
s->data=r;
for(p=in;p<in+n;p++)
if(*p==r)
break;
k=p-in;
s->lchild=CreatBT2(post,in,k);
s->rchild=CreatBT2(post+k,p+1,n-k-1);
return s;
}
已知二叉树后序中序,构造二叉树
最新推荐文章于 2022-03-05 21:34:49 发布