about | help | code help+videos | done | prefs |
binarySearch
Implement a recursive binary search method that searches a sorted int array for a given key, returning the index of that key if the element is found, and -1 if it is not found. You should not use loops. You will need to write a helper method that has additional parameters that allow indexes to be passed to indicate which part of the array is to be searched. The two-parameter method will have just one line of code in it: a line that calls the recursive binarySearch helper method. binarySearch([3, 5, 10, 20, 25], 3) → 0 binarySearch([3, 5, 10, 20, 25], 10) → 2 binarySearch([3, 5, 10, 20, 25], 25) → 4 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 200
Copyright Nick Parlante 2017 - privacy