Recursive Search Practice Quiz

Practice Problem

/**
 * @return the index of value in the sorted array data, or -1 if value is not in the array.
 */
public static int binarySearch(int[] data, int value) { // the data array is sorted.
  // your code here.
  // you can use a recursive helper method
}

The binary search algorithm decides which half of the array the value is in by comparing the value to the middle of the array then searching the correct half.

Time Remaining:

You can restart the timer by reloading the page.

Try to complete the problem in 15 minutes.

If you cannot complete the program in 15 minutes, you can watch me solve the problem in a text editor.