Files
JavaScript/Search/test/InterpolationSearch.test.js
Ankush263 85f428e826 merge: Add test case to Interpolation Search Algorithm (#1045)
* Add test case to Interpolation Search Algorithm

* Updated Documentation in README.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2022-06-13 22:17:18 +05:30

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)
})