diff --git a/Sorting/bucketSort.cpp b/Sorting/bucketSort.cpp new file mode 100644 index 000000000..278da92bd --- /dev/null +++ b/Sorting/bucketSort.cpp @@ -0,0 +1,42 @@ +// C++ program to sort an array using bucket sort +#include +#include +#include +using namespace std; + +// Function to sort arr[] of size n using bucket sort +void bucketSort(float arr[], int n) +{ + // 1) Create n empty buckets + vector b[n]; + + // 2) Put array elements in different buckets + for (int i=0; i