From 95e065e284c539e89e47005c93881c6375c00172 Mon Sep 17 00:00:00 2001 From: 2400031832 <2400031832@kluniversity.in> Date: Tue, 25 Nov 2025 12:31:18 +0530 Subject: [PATCH] Enhance docstring with complexity analysis Added time and space complexity analysis to the docstring. --- sorts/selection_sort.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sorts/selection_sort.py b/sorts/selection_sort.py index 506836b53e44..213c219fd8c5 100644 --- a/sorts/selection_sort.py +++ b/sorts/selection_sort.py @@ -5,6 +5,9 @@ def selection_sort(collection: list[int]) -> list[int]: :param collection: A list of integers to be sorted. :return: The sorted list. + + Time Complexity: O(n^2) - where n is the length of the collection. + Space Complexity: O(1) - in-place sorting, only uses constant extra space. Examples: >>> selection_sort([0, 5, 3, 2, 2]) [0, 2, 2, 3, 5]