X1223: Binary Search (int)

Complete the following binary search method on integers. Find the number search in the array numbers. Return the index of the element if found, -1 if the number is not found. You may assume the array is properly ordered.

Examples:

binarySearch({1,4,7},7) -> 2
binarySearch({2,6,6,8,80},6) -> 2

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.