Binary search

.
Last edited on
The left index can't overcome the right index but can be equal to, if the element is not found.
@Thomas1965:

But the loop condition has <= so why won't it go forever?
Actually I was wrong. Left can be greater than right when the element is not found and then the loop ends
Because it'll increment low by mid+1 so eventually it'll be bigger than high?
Topic archived. No new replies allowed.