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