题目描述:判断二叉树是否是二叉排序树。
KeyType predt = -32767;
int JudgeBST(BiTree bt){
int b1,b2;
if(bt == NULL)
return 1;
else{
b1 = JudgeBST(bt->lchild); //判断左子树是否是二叉排序树
if(b1 == 0 || predt >= bt->data) //若左子树返回值为0 或前驱大于或等
//于当前结点则不是二叉排序树
return 0;
predt = bt->data; //保存当前结点的关键字
b2 = JudgeBST(bt->rchild); //判断右子树
return b2; //返回右子树的结果
}
}