有没有已知二叉树而求判定是否是二叉排序树的算法原代码

来源:百度知道 编辑:UC知道 时间:2024/06/05 13:13:17

问题太犀利

typedef struct bitnode
{
int data;
struct bitnode *lchild,*rchild;
}bitnode,*bitree;
void sortbitree(bitree root)
{
bitree s[100];bitree t[100];int top=0;int k=0;
while(root||top)
{
while(root)
{
s[++top]=root;root=root->lchild;
}
if(top)
{
t[k++]=s[top];
root=s[top--]->rchild;
}
}
for(int i=0;i<k-1;i++)
if(t[i]->data>=t[i+1]->data){printf("不是二叉排序树\n");return;}
printf("是二叉排序树\n");
}