我正在编写此代码以查找二叉树是否是BST,但在调用函数时遇到错误:
bool IsBST1(struct node * root){
if(root==NULL)
return true;
if(IsSubtreeLesser(root->left,root->data) && IsSubtreeGreater(root->right,root->data) && IsBST(root->left) && IsBST(root->right)){
return true;
}
else{
return false;
}
}
bool IsSubtreeLesser(struct node * root,int value){
if(root==NULL){
return true;
}
if(root->data <= value && IsSubtreeLesser(root->left,value) && IsSubtreeLesser(root->right,value)){
return true;
}
else{
return false;
}
}
bool IsSubtreeGreater(struct node * root,int value){
if(root==NULL){
return true;
}
if(root->data > value && IsSubtreeGreater(root->left,value) && IsSubtreeGreater(root->right,value)){
return true;
}
else{
return false;
}
}
在调用函数IsBST1时,出现以下错误: 错误:“ IsSubtreLesser”的类型冲突