The idea of the PHP binary lookup method is to give me an array like this & nbsp; I add 2 to the header and end indexes of the array to get the index at the intermediate position. take the value of the number I am looking for and compare it with the value at the intermediate index position. if it is equal, this intermediate position is returned.. if the value at the intermediate position is greater than the value you want to search for, use the index at the intermediate position as the final index, and then add 2 to the first index to get the comparison of the intermediate index, if the value at the intermediate position is smaller than the value to be searched, the intermediate PHP binary query is performed.
The idea of the bipartite method is to give me an array. I add the first and last indexes of the array in addition to 2, so that we can get the index in the middle and get the value of the number I am looking for and the intermediate index position. to compare
If they are equal, the index at the intermediate position is returned. if the value at the intermediate position is greater than the value to be searched, the index at the intermediate position is used as the final index, and then the index is added to the header index to get the intermediate index comparison,
If the value at the intermediate position is smaller than the value to be searched, the index at the intermediate position is used as the header index, and then the index is added to the end index to get the comparison of the intermediate index.
(2*$m)){ $m= (int)(($m+$EndPos)/2)+1; } }else if($arr[$m] > $Num){ $EndPos = (int)$m; $m= (int)(($m+$StartPos)/2); } } return $m; }?>