To find max node data in bst

did not understand last statement- return max(node.right). we need to find the right node then why we are returning this node.right

HI @Gurneha-Kaur-2061937590530837,
See in this you do not return node.right but instead you are recursively calling the max function on node.right node. so as in the given case you will start with 40 which is the root node and then your max function will check whether it is having a node on right or not. If there is a node on right like in this case it is 60 you again do a recursive call on 60 . so then for 70 you check whether it has a right node and now it will return false hence the if statement of code will run and the code will return 70 .
So basically you are finding the answer recursively

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.