about | help | code help+videos | done | prefs |
Binary Search - Your task is to create a method that searches through a primitive array (int[]). The method should return an array of size 2: the first element is the value at the midpoint where the search converged, and the second element is the value at the previous midpoint checked before the last comparison. If the target value is not found, the method should still return the last midpoint value and the previous value examined. These values will help you trace how the binary search narrows down the search space and finds (or fails to find) the target efficiently. binarySearch([1, 2, 3, 4, 5, 6, 7], 7) → [7, 6] binarySearch([5, 6, 7, 8, 9, 10], 8) → [8, 9] binarySearch([1, 9, 19, 22, 30, 33, 44, 60, 65, 82, 89, 94, 99], 22) → [22, 30] ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Copyright Nick Parlante 2017 - privacy