langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
17
Task/Binary-search/BASIC/binary-search-2.basic
Normal file
17
Task/Binary-search/BASIC/binary-search-2.basic
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
FUNCTION binary_search ( array() AS Integer, value AS Integer, lo AS Integer, hi AS Integer) AS Integer
|
||||
DIM middle AS Integer
|
||||
|
||||
WHILE lo <= hi
|
||||
middle = (hi + lo) / 2
|
||||
SELECT CASE value
|
||||
CASE IS < array(middle)
|
||||
hi = middle - 1
|
||||
CASE IS > array(middle)
|
||||
lo = middle + 1
|
||||
CASE ELSE
|
||||
binary_search = middle
|
||||
EXIT FUNCTION
|
||||
END SELECT
|
||||
WEND
|
||||
binary_search = 0
|
||||
END FUNCTION
|
||||
Loading…
Add table
Add a link
Reference in a new issue