Navigation Menu

Skip to content
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

sort: TestAdversary is broken #21581

Closed
tom93 opened this issue Aug 24, 2017 · 1 comment
Closed

sort: TestAdversary is broken #21581

tom93 opened this issue Aug 24, 2017 · 1 comment

Comments

@tom93
Copy link
Contributor

tom93 commented Aug 24, 2017

There are some major problems with TestAdversary (based on A Killer Adversary for Quicksort by M. D. McIlroy).

  1. The data field is modified by Swap() but ignored by Less(), so swapping has no effect.

  2. Less() compares elements using >=, which is messed up.

  3. The test never checks anything, so it will always pass. It should count the number of comparisons and fail if there are too many.

  4. The size 100 is too small to distinguish between O(n^2) with a small constant factor and O(n*log(n)).

  5. (nitpicking) map[int]int can be replaced with []int, which is much more efficient.

@gopherbot
Copy link

Change https://golang.org/cl/58330 mentions this issue: sort: fix TestAdversary

@golang golang locked and limited conversation to collaborators Aug 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants