Recursion first occurrence

sir thanks for such a great explanation ,
sir I do understand the logic but my question is since in the base case we have already returned -1 if the key is not present ,so why do we return -1 again after the if statement??
like in the course example:
if(i==-1)
return -1;
why do you write again here?

This is used because for this particular call we have to terminate the function as well.
During this call we already passed the base case and made further calls. To end the existing call, we needed the extra if.

but sir why do not you do the same thing in the other version which has i as a parameter?
we do not write if condition statement although we can achieve -1 case??

Are you talking about linear search function? In that returning one thing works for all cases, but in the recurrence case we need to write it separately. As we return -1 for bad case , and i+1 if we don’t have bad case.

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.