Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
PHP - BinarySearch (Find-element-in-circular-sorted-array)
<?php //php 7.0.8 $data = [7,8,1,2,3,4,5,6]; $search = 8; echo find($data, $search); function find($data, $search) { $low = 0; $high = sizeof($data)-1; while ($low <= $high) { $mid = $low + (int)(($high-$low)/2); if ($search == $data[$mid]) { return $mid; } else if($data[$mid] <= $data[$high]) { if ($search > $data[$mid] && $search <= $data[$high]) { $low = $mid + 1; } else { $high = $mid - 1; } } else { if ($data[$low] <= $search && $search < $data[$mid]) { $high = $mid - 1; } else { $low = $mid + 1; } } } return -1; } ?>
run
|
edit
|
history
|
help
3
unset によるオブジェクトのプロパティの削除と配列の要素の削除の検証
PHP - BinarySearch (Recursive method)
$$¤ Cash App Free Money ¤$$
utf8 chinese char
задача countBasket
seat_taken_table_card_kuy09
kuy09
php
Hello. Php
PHP reference ,( returning specific array index for additional to be added on the fly)