Added complexities

This commit is contained in:
NoodlesIAte 2024-10-04 10:06:58 +05:30 committed by GitHub
parent 40f65e8150
commit 8db8f5b24b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -26,6 +26,15 @@ def quick_sort(collection: list) -> list:
[]
>>> quick_sort([-2, 5, 0, -45])
[-45, -2, 0, 5]
Time Complexity:
Best Case: O(n log n)
Average case: O(n log n)
Worst Case: O(n^2)
Space Complexity:
Best Case: O(log n)
Worst Case: O(n)
"""
# Base case: if the collection has 0 or 1 elements, it is already sorted
if len(collection) < 2: