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>
This commit is contained in:
Ankush263
2022-06-13 22:17:18 +05:30
committed by GitHub
parent 59760f75c4
commit 85f428e826

View File

@ -0,0 +1,15 @@
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)
})