First, the binary search (binary search)
Material Preparation: array arr, find an element x, the index number l, mid intermediate index
Method Function: len ()
Function name: binarySearch (arr, l, r, x)
Analyzing index and core algorithms: mid = int (l + (r - 1) / 2)
Algorithm performs the steps of:
First, the definition of an array
arr = [2,3,4,5,6,7]
x = 4
Second, the binary search function body
Text idea: the function body has four parameters, namely the array, the index number, the maximum array index, find elements.