Heim > Artikel > Backend-Entwicklung > php2分查找法
php二分查找法
?
?function bin_sch($array,$low,$heigh,$k){
??if($low ???$mid = intval(($low + $heigh)/2);
???
???if($array[$mid] == $k){
????return true;
???}else if($k ????return bin_sch($array, $low, $mid-1, $k);
???}else {
????return bin_sch($array, $mid+1, $heigh, $k);
???}
??}
?}
?>