Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,7 @@
binarySearch = function(A, value, low, high)
if high < low then return null
mid = floor((low + high) / 2)
if A[mid] > value then return binarySearch(A, value, low, mid-1)
if A[mid] < value then return binarySearch(A, value, mid+1, high)
return mid
end function

View file

@ -0,0 +1,15 @@
binarySearch = function(A, value)
low = 0
high = A.len - 1
while true
if high < low then return null
mid = floor((low + high) / 2)
if A[mid] > value then
high = mid - 1
else if A[mid] < value then
low = mid + 1
else
return mid
end if
end while
end function