Even if we get away with both if conditions we still will get same results. Right ?

Those if’s are there to confuse us to think that this is like binary search. Right ?

# Isn’t the if conditions useless?

right. the if cases are never satisfied , the only thing that runs is return statement

if cases are doing the comparison. if we remove it then 1 will be added in all call (last statement of the code). So

- if you remove these if statements (including corresponding return statement) then the result should be size of the array always. As there will be no check of equality in this case.
- if you remove only if cases then array jump beyond its range in various scenario.

In fact all the logic is there in these two if statements and 1 is added only if k is equal to V[mid].

both IF,s are there for right purpose as if we see the best case then we consider the array to be sorted and distinct in that case array will be divided in two parts and only one part will be checked and in that case answer will be equal to binary search.