Add Smoothsort algorithm implementation#13534
Conversation
This adds the Smoothsort adaptive sorting algorithm by Edsger Dijkstra. It runs in O(n log n) worst case and O(n) when data is nearly sorted.
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
| [1, 2, 2, 3, 3] | ||
| """ | ||
|
|
||
| def sift(start: int, size: int) -> None: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file sorts/smoothsort.py, please provide doctest for the function sift
Updated comments and documentation for clarity on the smoothsort algorithm. Refactored internal helper function name and removed redundant code for Leonardo numbers.
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
| for _ in range(2, 24): | ||
| leonardo.append(leonardo[-1] + leonardo[-2] + 1) | ||
|
|
||
| def _sift(start: int, size: int) -> None: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file sorts/smoothsort.py, please provide doctest for the function _sift
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
| for _ in range(2, 24): | ||
| leonardo.append(leonardo[-1] + leonardo[-2] + 1) | ||
|
|
||
| def _sift(start: int, size: int) -> None: |
There was a problem hiding this comment.
As there is no test file in this pull request nor any test function or class in the file sorts/smoothsort.py, please provide doctest for the function _sift
This adds the Smoothsort adaptive sorting algorithm by Edsger W. Dijkstra.
Describe your change:
Checklist: