See On Github

Wikipedia Description

In computer science, a binary search or half-interval search algorithm finds the position of a target value within a sorted array. The binary search algorithm can be classified as a dichotomic divide and conquer search algorithm and executes in logarithmic time . The binary search algorithm begins by comparing the target value to value of the middle element of the sorted array. If the target value is equal to the middle element's value, the position is returned. If the target value is smaller, the search continues on the lower half of the array, or if the target value is larger, the search continues on the upper half of the array. This process continues until the element is found and its position is returned, or there are no more elements left to search for in the array and a not found indicator is returned. This rather simple game begins something like I'm thinking of an integer between forty and sixty inclusive, and to your guesses I'll respond 'Higher', 'Lower', or 'Yes!' as might be the case. Supposing that N is the number of possible values (here, twenty-one, as inclusive was stated), then at most questions are required to determine the number, since each question halves the search space. Note that one less question (iteration) is required than for the general algorithm, since the number is already constrained to be within a particular range.

recursion, search