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

php2分查找法

WBOY
Release: 2016-06-13 13:13:46
Original
911 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template