What is going wrong in this code


made a minor change
in the calling u have to send the previous node i.e. the current root since that will be the new max for left and new min for right
u were sending the next number in thee array since ur i was incremented before the call