Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sorts/insertion_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def __lt__(self, other: Any, /) -> bool: ...
def insertion_sort[T: Comparable](collection: MutableSequence[T]) -> MutableSequence[T]:
"""A pure Python implementation of the insertion sort algorithm
Time Complexity: O(n^2) worst case, O(n) best case (already sorted)
Space Complexity: O(1) auxiliary
:param collection: some mutable ordered collection with heterogeneous
comparable items inside
:return: the same collection ordered by ascending
Expand Down