Home >Backend Development >PHP Tutorial > php2分查找法

php2分查找法

WBOY
WBOYOriginal
2016-06-13 13:13:46905browse

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);
???}
??}
?}
?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn