mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-07 11:08:54 +08:00

* Add test case to Interpolation Search Algorithm * Updated Documentation in README.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
16 lines
486 B
JavaScript
16 lines
486 B
JavaScript
import { interpolationSearch } from '../InterpolationSearch'
|
|
|
|
test('interpolationSearch([2, 6, 8, 14, 122, 169], 144) => -1', () => {
|
|
const array = [2, 6, 8, 14, 122, 169]
|
|
const key = 144
|
|
const res = interpolationSearch(array, key)
|
|
expect(res).toEqual(-1)
|
|
})
|
|
|
|
test('interpolationSearch([2, 6, 8, 14, 122, 169], 122) => 4', () => {
|
|
const array = [2, 6, 8, 14, 122, 169]
|
|
const key = 122
|
|
const res = interpolationSearch(array, key)
|
|
expect(res).toEqual(4)
|
|
})
|