Skip to content

Commit 95e065e

Browse files
authored
Enhance docstring with complexity analysis
Added time and space complexity analysis to the docstring.
1 parent a051ab5 commit 95e065e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sorts/selection_sort.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ def selection_sort(collection: list[int]) -> list[int]:
55
:param collection: A list of integers to be sorted.
66
:return: The sorted list.
77
8+
9+
Time Complexity: O(n^2) - where n is the length of the collection.
10+
Space Complexity: O(1) - in-place sorting, only uses constant extra space.
811
Examples:
912
>>> selection_sort([0, 5, 3, 2, 2])
1013
[0, 2, 2, 3, 5]

0 commit comments

Comments
 (0)