-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
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
tests in search
#575
Comments
Hello, would like to contribute to this. Can you assign the task? |
I agree with |
For the test cases that are present in the tests, they are correct. I argue that those specific test cases should be added on case by case basis rather than uniformly adding them in tests separately for each test. |
I don`t think the Binary func is useful when the array has repeated elements, maybe we can just refer to the sort.Search func in the standard library, which has a more clear and strict definition. |
The search functions cannot be treated uniformly in tests. The issue arises when the input array contains duplicated entries.
Consider the example when we want to fund the index of
4
in the array[1, 2, 4, 4, 4, 6, 7, 8, 9, 10]
(note that the array is sorted):Binary
andBinaryIterative
will return 4,Jump2
will return 4,Linear
andInterpolation
will return 2.Jump
will return 2.To summarize the functions like
Linear
orInterpolation
return the smallest index of the searched element (if it exists in the array). While other functions likeBinary
orJump2
return some index.I think the above shows a need to change tests or/and the implementations of the
search
package (for example theInterpolation
function could be simplified to find some index).The text was updated successfully, but these errors were encountered: