A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
17
Task/Binary-search/Maple/binary-search-2.maple
Normal file
17
Task/Binary-search/Maple/binary-search-2.maple
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
BinarySearch := proc( A, value )
|
||||
description "iterative binary search";
|
||||
local low, high;
|
||||
|
||||
low, high := ( lowerbound, upperbound )( A );
|
||||
while low <= high do
|
||||
local mid := iquo( low + high, 2 );
|
||||
if A[ mid ] > value then
|
||||
high := mid - 1
|
||||
elif A[ mid ] < value then
|
||||
low := mid + 1
|
||||
else
|
||||
return mid
|
||||
end if
|
||||
end do;
|
||||
FAIL
|
||||
end proc:
|
||||
Loading…
Add table
Add a link
Reference in a new issue