Largets bst in a tree


on compilation why this code is showing error

you have take only 2 parameters which is insufficient for judging whether the tree is bst or not
for checking bst we have to check 3 conditions

  1. root->data>root->left->data && root->dataright->data
    2)left subtree should be bst
    3)right subtree should be bst
    you have checked only one

https://ide.codingblocks.com/s/217741 this is the code i am using now and still getting error

if(left.isbst && right.isbst && root->data>left.leftmax && root->data<right.rightmin)
now you miss your previous condition
root->data>left->data&&root->datadata

@dakshi
Line 65 and 66.
int j=0;
for(int j=s;j<=e;j++)
You have initialised a new j for the loop. This is the one that will iterate. However the value of j in the function scope remains 0. So when you make a recursive call with j-1 and j+1 , it will be made with -1 and 1 always.