powered by
Finds the index of the bin a number belongs to using naive search.
naiveSearch_bin(arr, x)
The index i such that arr[i] <= x <= arr[i+1].
i
arr[i] <= x <= arr[i+1]
A vector of size at least 2.
A number. Must be within the range of [arr[1], arr[length(arr)]].
arr[1]
arr[length(arr)]
Finds the smallest index i such that arr[i] <= x <= arr[i+1].
naiveSearch_bin(1:10, seq(1, 10, by=0.5))
Run the code above in your browser using DataLab