Friday, 13 September 2013

Why is (insertion_point - 1) returned by Collections.binarySearch when an element not present and not insertion_point?

Why is (insertion_point - 1) returned by Collections.binarySearch when an
element not present and not insertion_point?

Been using the binarySearch method and wondering why is -(insertion_point
- 1) returned by Collections.binarySearch when an element not present and
not -insertion_point? I understand why it is negative, but why the -1?

No comments:

Post a Comment