We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The RSelect method is not returning the correct k-smallest element.
Here is an example:
arr := []int{5, 2, 6, 8, 3, 1} x := RSelect(arr, 6, 0) fmt.Println("Value: ", x)
The printed value is 5, when it should be 1.
5
1
The test implemented for RSelect is running successfully, showing that it was implemented incorrectly.
There is an error in the applied boolean logic. The test is using && to validate the returned values, when it should be using ||.
&&
||
Here is the correct test implementation:
func TestRSelect(t *testing.T) { arr := []int{5, 2, 6, 8, 3, 1} i0 := RSelect(arr, 6, 0) i1 := RSelect(arr, 6, 1) i2 := RSelect(arr, 6, 2) i3 := RSelect(arr, 6, 3) i4 := RSelect(arr, 6, 4) i5 := RSelect(arr, 6, 5) if i0 != 1 || i1 != 2 || i2 != 3 || i3 != 5 || i4 != 6 || i5 != 8 { fmt.Println("Error: ", i0, i1, i2, i3, i4, i5) t.Error() } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Problem
The RSelect method is not returning the correct k-smallest element.
Here is an example:
The printed value is
5
, when it should be1
.Test
The test implemented for RSelect is running successfully, showing that it was implemented incorrectly.
There is an error in the applied boolean logic. The test is using
&&
to validate the returned values, when it should be using||
.Here is the correct test implementation:
The text was updated successfully, but these errors were encountered: