From 1dc9ec8fb2c51372800762b8e3f734eb93ec1814 Mon Sep 17 00:00:00 2001 From: obelisk0114 Date: Fri, 12 Jul 2019 08:16:14 -0700 Subject: [PATCH] Update Bucket Sort time complexity analysis (#918) --- 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 5c4a71513..0678b1194 100644 --- a/sorts/bucket_sort.py +++ b/sorts/bucket_sort.py @@ -17,7 +17,12 @@ # 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