小于 1 分钟
Home > @hz-9/algorithm > binaryTreeSearch
binaryTreeSearch() function
Sequential search algorithm.(BinarySearchTree) Input parameters do not need to be sorted.
线性搜索算法。(二叉搜索树) 传入参数必须已经进行从小到大排序。
Signature:
binaryTreeSearch: <T>(list: T[], value: T, compareFn?: CompareFn<T>) => numberParameters
Parameter | Type | Description |
|---|---|---|
list | T[] | The list to search. |
value | T | The value to search for. |
compareFn | CompareFn<T> | (Optional) The compare function. |
Returns:
number
- The index of the value in the list. If the value is not found, return -1.