Skip to content

Improve selection sort doctests and documentation#14459

Closed
23f3003167 wants to merge 1 commit intoTheAlgorithms:masterfrom
23f3003167:improve/selection-sort-doctests
Closed

Improve selection sort doctests and documentation#14459
23f3003167 wants to merge 1 commit intoTheAlgorithms:masterfrom
23f3003167:improve/selection-sort-doctests

Conversation

@23f3003167
Copy link

Summary

  • Improve the selection sort docstring with a short explanation of how the algorithm works.
  • Add complexity notes:
    • Time complexity: O(n^2)
    • Space complexity: O(1)
  • Expand doctest coverage from 3 to 11 examples.

Why this is useful

This repository is used by learners. More examples and clearer documentation make the behavior easier to understand, especially for edge cases.

Validation

  • Ran doctests for this file locally.
  • Result: 11 passed, 0 failed.

Scope

  • Changed one file only: sorts/selection_sort.py
  • No algorithm logic changes, only documentation and doctests.

If you want, I can also give you a shorter version (2-3 lines) in case maintainers prefer minimal PR descriptions.

- Add detailed algorithm description explaining the approach
- Document time complexity O(n²) and space complexity O(1)
- Add 11 comprehensive doctest examples covering:
  - Basic cases (already covered)
  - Edge cases (single element, empty list)
  - Sorted/reverse-sorted inputs
  - Lists with duplicates
  - Verification against standard library sorted() function

These improvements help new learners understand the algorithm better and verify correctness across diverse inputs.
@algorithms-keeper
Copy link

Closing this pull request as invalid

@23f3003167, this pull request is being closed as none of the checkboxes have been marked. It is important that you go through the checklist and mark the ones relevant to this pull request. Please read the Contributing guidelines.

If you're facing any problem on how to mark a checkbox, please read the following instructions:

  • Read a point one at a time and think if it is relevant to the pull request or not.
  • If it is, then mark it by putting a x between the square bracket like so: [x]

NOTE: Only [x] is supported so if you have put any other letter or symbol between the brackets, that will be marked as invalid. If that is the case then please open a new pull request with the appropriate changes.

@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Mar 27, 2026
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 invalid

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant