-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Description
by mimenarrator:
The Go sort library implements quicksort, which has a worst-case runtime of O(n^2), and not introsort, with a worst case runtime of O(n*log(n)), as, for example, GNU's libstdc++ does. Introsort almost always uses the same algorithm as quicksort, but when pathological cases are detected that lead to O(n^2) runtime of quicksort (by keeping track of the recursion depth), heapsort is used instead, since it is guaranteed O(n*log(n)), though on average slower than quicksort. This is obviously not of the highest priority, especially given the rarity of pathological cases for the quicksort implementation used in Go, but they do exist, and can, for example, but exploited in denial of service attacks.