Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct odp{
- int height;
- bool ok;
- };
- odp ifBST(BSTnode * root){
- odp o;
- o.ok=true;
- if(root == NULL){
- o.height=0;
- }
- else{
- odp leftHeight = ifBST(root->left) , rightHeight = ifBST(root->right);
- if(abs(leftHeight.height-rightHeight.height)>1){
- o.ok=false;
- }
- o.height = 1 + max(leftHeight.height, rightHeight.height);
- }
- return o;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement