Skip to content

Commit f7da27b

Browse files
committed
Add insertion sort complexity details
1 parent e3b01ec commit f7da27b

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
@@ -31,6 +31,9 @@ def insertion_sort[T: Comparable](collection: MutableSequence[T]) -> MutableSequ
3131
comparable items inside
3232
:return: the same collection ordered by ascending
3333
34+
Time complexity: O(n) in the best case, O(n^2) in the average and worst cases
35+
Space complexity: O(1)
36+
3437
Examples:
3538
>>> insertion_sort([0, 5, 3, 2, 2])
3639
[0, 2, 2, 3, 5]

0 commit comments

Comments
 (0)