Skip to content

feat: add Reversort sorting algorithm - #14482

Merged
cclauss merged 2 commits into
TheAlgorithms:masterfrom
xingzihai:add-reversort-algorithm
Sep 9, 2026
Merged

cclauss merged 2 commits into
TheAlgorithms:masterfrom
xingzihai:add-reversort-algorithm

Conversation

@xingzihai

Copy link
Copy Markdown
Contributor

Closes #11800

Description

Added implementation of the Reversort sorting algorithm as described in the Google Code Jam 2021 problem.

Algorithm

Reversort is a sorting algorithm that works by:

  1. For each position i from 1 to N-1
  2. Find the minimum element in the remaining unsorted portion
  3. Reverse the subarray from i to the position of the minimum element

Testing

  • Added test cases covering various input scenarios
  • All tests pass locally

Checklist

  • Code follows the repository style
  • Added appropriate test cases
  • All tests pass

- Add reversort.py with Reversort algorithm implementation
- Algorithm from Google Code Jam 2021 Qualification Round
- Time complexity: O(n²)
- Space complexity: O(n) due to slicing, can be O(1) with in-place reversal
- Includes reversort() for sorting and reversort_cost() for computing cost
- Comprehensive doctests included
@algorithms-keeper algorithms-keeper Bot added the awaiting reviews This PR is ready to be reviewed label Mar 29, 2026
@xingzihai
xingzihai force-pushed the add-reversort-algorithm branch from e544ad2 to af84c75 Compare March 29, 2026 23:50
@algorithms-keeper algorithms-keeper Bot removed the awaiting reviews This PR is ready to be reviewed label Sep 9, 2026
@cclauss
cclauss merged commit cd94f1a into TheAlgorithms:master Sep 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reversort is missing

3 participants