Add slowsort algorithm#14717
Open
dipeshrayg wants to merge 1 commit into
Open
Conversation
diusazzad
suggested changes
May 25, 2026
|
|
||
| doctest.testmod() | ||
|
|
||
| user_input = input("Enter numbers separated by commas: ").strip() |
There was a problem hiding this comment.
I have one minor suggestion regarding the user input block at the bottom (72-76):
If a user enters an empty string or non-integer values, [int(x) for x in user_input.split(",")] will raise a ValueError.You can make this more robust like -Wrap the input section in a try-except block to handle invalid inputs gracefully.Great job overall! Let me know what you think.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your change:
Adds Slowsort in
sorts/slowsort.py.Slowsort is a deliberately inefficient recursive sorting algorithm based on the
"multiply and surrender" paradigm, invented by Broder and Stolfi (1986). It
finds the maximum of two halves, places it at the end, then recurses — the
opposite of divide and conquer. Runs in superpolynomial time, making it a
classic example in pessimal algorithm analysis.
Reference: https://en.wikipedia.org/wiki/Slowsort
Checklist: