when bhaiya returned 0 at line 14 then how function will return i+1 at the last line ?
In this video when he return 0 at line 14
@Tanishq_Gupta it is done because when the value returned from the recursive call is -1. then it means that key is not present in the part of array, so that when compared with a[0] and found key then it means that it is present at index=0 of current array, so it returned -1, then later on the previous recursuve call will add 1 to it.
We dont need to add 1, because it is found at 0th index of the array which is present for the current recursive call.
I hope this clears your doubt. It doesn’t clear i will suggest you to rewatch the starting part of the video where bhaiya has explained the recursive calls.
Feel free to ask.
If you understood it then please mark this doubt as resolved.
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.