diff --git a/bucket_sort.h b/bucket_sort.h new file mode 100644 index 0000000..325bf58 --- /dev/null +++ b/bucket_sort.h @@ -0,0 +1,40 @@ +//BUCKET SORT + // Best case performance Ω(n+k) +// Average case performace θ(n+k) +// Worst Average case performace O(n^2) +// Wost case space complexity O(n) + //https://en.wikipedia.org/wiki/Bucket_sort + // The following header files are a must in order to execute the following code +#include +#include +#include +using namespace std; + +// Function to sort arr[] of size n using bucket sort +template +void bucketSort(T arr[], int n) +{ + // 1) Create n empty buckets + vector b[n]; + + // 2) Put array elements in different buckets + for (int i=0; i