Please help with Bottom-up Approach for Check for BST problem

Please share code for Bottom-up Approach for Check for BST problem.

Reference Code

I am not able to differentiate between bottom-up and top-down approach in case of a tree. Please explain.

In BOTTOM UP approach
we try to build our solution by integrating the ans of sub-problems

In TOP DOWN approach
we do the things while going down the tree

bool isBST(node *root,int minV = INT_MIN,int maxV = INT_MAX){

if(root==NULL){

    return true;

}

if(root->data >= minV && root->data<=maxV && isBST(root->left,minV,root->data) && isBST(root->right,root->data,maxV)){

    return true;

}

return false;

}
This is the Top-down code discussed by sir in the video and in it just like bottom-up, we first we go till the leaf node and then during coming back to root we return true/false. Then what is the difference??

in this code first we are checking the current node’s condition
that root->data >=minV
if it’s true then we go down

but in bottom up
first we go down and while going up we decide things

I think you are not seeing both codes side by side they are both same, both check for root->data to be in exact range and return false if not else go to left or right node.
what is the difference??

Yes both are same and it is top-down approach
In bottom up we build our solution from the smallest possible ans and
in top down we take the bigger problem and try to solve by breaking it into the smaller parts.

for this question bottom up is not solution

lets take the example of fibo number series

Top Down Approach v/s Bottom Up Approach

bro that was the whole point of me asking this doubt. I clearly know difference between TD and BU. But what is the difference between top-down and bottom-up approach in case of tree because to me both look same but sir said that they are different.

hey @aman212yadav can you please solve this query…its been 2 days and its is not solved

@sahilkhan2312000131
pls raise another doubt , i will help u there

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.