Description Usage Arguments Value Examples
View source: R/binary_search.R
The function applies the generic binary search algorithm to search if the value x exists in the lst, and returns a vector contains: TRUE/FAlSE depends on whether the x value has been found, x value, and x position index in lst
1 | binary_search(x, lst)
|
x |
: numeric value less than 1000. |
lst |
: sorted vector of numerics |
a list: First character represents a logical value (TRUE/FALSE). Second character represents a numeric value of x. Third character represents a numeric in range of 1 to length(lst) where NA indicates the element is not in the list
1 2 3 4 5 | binary_search(4, c(1,2,3,4,5,6))
c('TRUE','4','4')
binary_search(5, c(10,100,200,300))
c('FALSE','5','0')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.