about | help | code help+videos | done | prefs |
binarySearch
Define a function that when passed an integer array sorted in ascending order, and another integer, performs binary search to return an index, any index, at which the item exists in the array. Return -1 if the item does not exist in the array. Google "binary search" to see the algorithm. binarySearch([10, 20, 20, 20, 20, 70, 90], 10) → 0 binarySearch([10, 20, 20, 20, 20, 70, 90], 20) → 3 binarySearch([10, 20, 20, 20, 20, 70, 90], 70) → 5 ...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: 4 Post-solution available
Copyright Nick Parlante 2017 - privacy