int highAve(struct tree* root){
if(root == NULL)
return 0 ;
int lefthigh = highAve(root->left);
int righthigh = highAve(root->right);
if(abs(lefthigh - righthigh) >=2 )
return -1;
else
return max(lefthigh,righthigh);
}
bool isAve(struct tree* root){
if(highAve(root) == -1)
return false;
else
return true;
}
时间: 2024-11-14 13:30:31