educative.io

Can you please explain why you need to check target as left index outside of loop?

Hi,
In this lesson on binary search, it says " * Line 14: We must check the element on the left index outside the loop because if we skip the loop, it can become the target."
This reason is not clear to me, what do you mean by skipping the loop?
I have seen other implementations of binary tree search which are basically identical to this, which don’t check left index outside of the loop so I’d like to understand properly why you say it is necessary please.

Hi @Nessa_Swanson, please share the lesson/course link. Thanks!