From e96b4a30e86b67a34b030bc78603ea4f28265357 Mon Sep 17 00:00:00 2001 From: obelisk0114 Date: Wed, 26 Jun 2019 14:15:17 -0700 Subject: [PATCH] Update Bucket Sort time complexity analysis --- sorts/bucket_sort.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sorts/bucket_sort.py b/sorts/bucket_sort.py index c4d61874fc47..bd212ede4e10 100644 --- a/sorts/bucket_sort.py +++ b/sorts/bucket_sort.py @@ -11,7 +11,12 @@ # involve the number of buckets. # Time Complexity of Solution: -# Best Case O(n); Average Case O(n); Worst Case O(n) +# Worst case scenario occurs when all the elements are placed in a single bucket. The overall performance +# would then be dominated by the algorithm used to sort each bucket. In this case, O(n log n), because of TimSort +# +# Average Case O(n + (n^2)/k + k), where k is the number of buckets +# +# If k = O(n), time complexity is O(n) DEFAULT_BUCKET_SIZE=5