Skip to content

feat: add Reversort sorting algorithm#14482

Open
xingzihai wants to merge 2 commits intoTheAlgorithms:masterfrom
xingzihai:add-reversort-algorithm
Open

feat: add Reversort sorting algorithm#14482
xingzihai wants to merge 2 commits intoTheAlgorithms:masterfrom
xingzihai:add-reversort-algorithm

Conversation

@xingzihai
Copy link
Copy Markdown

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviews This PR is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reversort is missing

1 participant