Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
PHP - BinarySearch (Recursive method)
<?php //php 7.0.8 $data = [1,2,3,4,5,10,13,16,18,21,22,25]; $search = 10; echo binarySearch($data, $search, 0, sizeof($data)-1); function binarySearch($data, $search, $low, $high) { if ($low > $high) return -1; $mid = $low + (int) (($high - $low)/2); if ($data[$mid] == $search) { return $mid; } else if ($search > $data[$mid]) { $low = $mid + 1; return binarySearch($data, $search, $low, $high); } else { $high = $mid -1; return binarySearch($data, $search, $low, $high); } } ?>
run
|
edit
|
history
|
help
2
vina
PUBG Mobile Hack 2019 Free UC and BP - No Survey
is_numeric example
Emailes
bs
hangus
aa
Afnan Khan
Agência Mais Próxima PHP
split into chunks of 6