If we are already using a bool compare function to return a<=b the in line 15 why are we subtracting 1 from int lb=…
Why are we subtracting 1 in line 15?
I understand why are we subtracting 1 when we do not use compare function but I am asking why do we subtract 1 when we are using compare function which only return the value less than or equal to key.
@Ak07,
Because we wan’t less than or equal val, e.g if we want to search for 100, and there is a 100, we want index of 100.
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.