If I'm assigning here tm(Total max) with Integer.MIN_VALUE then I'm getting output like this -2147483648 . Why i'm getting this?

private int max(Node node) {
int tm = Integer.MIN_VALUE;
for(Node child: node.children) {
int cm = max(child);
if(cm>tm) {
tm = cm;
}
}

	return tm;
}

Hi @LakshmiPrasanna0303

You are getting this because it’s already defined in the library. Integer.MIN_VALUE is the minimum value of integer range which is -(2^31) = -2147483648.

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.

Yes I know that but please check the code I’m checking with the condition (cm>tm) then it should store the maximum value but why it is not going in the loop???

Hi @LakshmiPrasanna0303

This is because for the leaf node or base case, you max function will not run for loop and will directly return tm which will be Integer.MIN_VALUE only and that will be stored in cm.