Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int binarySearch(int value) {
- int start = 0, last = sizeData;
- while (start < last) {
- int midIndex = start + (last - start) / 2;
- int midElement = data[midIndex];
- if (value == midElement) return midIndex;
- if (value < midElement) last = midIndex;
- if (value > midElement) start = midIndex + 1;
- }
- return -1;
- }
Add Comment
Please, Sign In to add comment