langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
|
|
@ -1,30 +0,0 @@
|
|||
fn binarySearchRecursive arr value lower upper =
|
||||
(
|
||||
if lower == upper then
|
||||
(
|
||||
if arr[lower] == value then
|
||||
(
|
||||
return lower
|
||||
)
|
||||
else
|
||||
(
|
||||
return -1
|
||||
)
|
||||
)
|
||||
mid = (lower + upper) / 2
|
||||
if arr[mid] > value then
|
||||
(
|
||||
return binarySearchRecursive arr value lower (mid-1)
|
||||
)
|
||||
else if arr[mid] < value then
|
||||
(
|
||||
return binarySearchRecursive arr value (mid+1) upper
|
||||
)
|
||||
else
|
||||
(
|
||||
return mid
|
||||
)
|
||||
)
|
||||
|
||||
arr = #(1, 3, 4, 5, 6, 7, 8, 9, 10)
|
||||
result = binarySearchRecursive arr 6 1 arr.count
|
||||
Loading…
Add table
Add a link
Reference in a new issue