Skip to content

Commit 71d0265

Browse files
author
deepshekhardas
committed
docs(sorts): add complexity analysis to insertion_sort docstring
1 parent c0db072 commit 71d0265

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

sorts/insertion_sort.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ def __lt__(self, other: Any, /) -> bool: ...
2727
def insertion_sort[T: Comparable](collection: MutableSequence[T]) -> MutableSequence[T]:
2828
"""A pure Python implementation of the insertion sort algorithm
2929
30+
Time Complexity: O(n^2) worst case, O(n) best case (already sorted)
31+
Space Complexity: O(1) auxiliary
32+
3033
:param collection: some mutable ordered collection with heterogeneous
3134
comparable items inside
3235
:return: the same collection ordered by ascending

0 commit comments

Comments
 (0)