We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
trekhleb
Learn more about funding links in repositories.
Report abuse
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Details:
Some entries might cause interpolationSearch to fall into an infinite loop. Step to reproduce: interpolationSearch([0, 3], 6)
interpolationSearch
interpolationSearch([0, 3], 6)
How did I find it?
Thanks to property based testing framework fast-check. The property was the following:
import fc from 'fast-check'; fc.assert( fc.property( fc.array(fc.integer()).map(arr => [...arr].sort((a, b) => a - b)), fc.integer(), (arr, i) => expect(interpolationSearch(arr, i)).toBe(arr.indexOf(i)) ) )
Or:
for any arr - sorted array of integers - and i - integer value interpolationSearch(arr, i) should be equivalent to arr.indexOf(i)
arr
i
interpolationSearch(arr, i)
arr.indexOf(i)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Details:
Some entries might cause
interpolationSearch
to fall into an infinite loop.Step to reproduce:
interpolationSearch([0, 3], 6)
How did I find it?
Thanks to property based testing framework fast-check.
The property was the following:
Or:
The text was updated successfully, but these errors were encountered: