Less than 1 minute
Home > @hz-9/algorithm > interpolationSearch
interpolationSearch() function
Interpolation search algorithm. Input parameters must be sorted in ascending order.
内插搜索算法。 传入参数必须已经进行从小到大排序。
Signature:
interpolationSearch: <T>(array: T[], target: T, compareFn?: CompareFn<T>) => numberParameters
Parameter | Type | Description |
|---|---|---|
array | T[] | |
target | T | |
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.