manrajgrover / algorithms-js

Consumable Data Structures and Algorithms library in JavaScript
MIT License
198 stars 129 forks source link

interpolationSearch always returns -1 for array with duplicates #87

Closed umairnadeem closed 3 years ago

umairnadeem commented 5 years ago

Description

interpolationSearch always returns -1 even if value is included in an array with duplicates. For instance, if the input is [42,42,42] and the target element is 42, the interpolation search will return -1 although 42 is included in the array.

Versions

Expected behaviour

interpolationSearch should return 0.

Steps to recreate

Input an array with all the same values in interpolationSearch, and a target element which is included in the array.

People to notify

@manrajgrover

umairnadeem commented 5 years ago

I am working on a fix.