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-3.maple
Normal file
17
Task/Binary-search/Maple/binary-search-3.maple
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
> N := 10:
|
||||
> P := [seq]( ithprime( i ), i = 1 .. N ):
|
||||
> BinarySearch( P, 12, 1, N ); # recursive version
|
||||
FAIL
|
||||
|
||||
> BinarySearch( P, 13, 1, N ); # recursive version
|
||||
6
|
||||
|
||||
> BinarySearch( Array( P ), 13, 1, N ); # make P into an array
|
||||
6
|
||||
|
||||
> PP := Array( -2 .. 7, P ): # check it works if the array is not 1-based.
|
||||
> BinarySearch( PP, 13 ); # iterative version
|
||||
3
|
||||
|
||||
> PP[ 3 ];
|
||||
13
|
||||
Loading…
Add table
Add a link
Reference in a new issue