Class | Sorting algorithm |
---|---|
Data structure | Array |
Worst-case performance | O(n log n) |
Best-case performance | O(n) |
Average performance | O(n log n) |
Worst-case space complexity | O(n) total, O(1) auxiliary |
Optimal | When the data is already sorted |
In computer science, smoothsort is a comparison-based sorting algorithm. A variant of heapsort, it was invented and published by Edsger Dijkstra in 1981.[1] Like heapsort, smoothsort is an in-place algorithm with an upper bound of O(n log n) operations (see big O notation),[2] but it is not a stable sort.[3][self-published source?][4] The advantage of smoothsort is that it comes closer to O(n) time if the input is already sorted to some degree, whereas heapsort averages O(n log n) regardless of the initial sorted state.
One can also raise the question why I have not chosen as available stretch lengths: ... 63 31 15 7 3 1 which seems attractive since each stretch can then be viewed as the postorder traversal of a balanced binary tree. In addition, the recurrence relation would be simpler. But I know why I chose the Leonardo numbers:(transcription)
hertel
was invoked but never defined (see the help page).Smoothsort is not stable, and stability is often more desirable than in-place in practice