Skip to content

Commit 8db8f5b

Browse files
authored
Added complexities
1 parent 40f65e8 commit 8db8f5b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

sorts/quick_sort.py

+9
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ def quick_sort(collection: list) -> list:
2626
[]
2727
>>> quick_sort([-2, 5, 0, -45])
2828
[-45, -2, 0, 5]
29+
30+
Time Complexity:
31+
Best Case: O(n log n)
32+
Average case: O(n log n)
33+
Worst Case: O(n^2)
34+
35+
Space Complexity:
36+
Best Case: O(log n)
37+
Worst Case: O(n)
2938
"""
3039
# Base case: if the collection has 0 or 1 elements, it is already sorted
3140
if len(collection) < 2:

0 commit comments

Comments
 (0)