diff --git a/bucket_sort.cpp b/bucket_sort.cpp new file mode 100644 index 0000000..f612482 --- /dev/null +++ b/bucket_sort.cpp @@ -0,0 +1,79 @@ + +// C++ program to sort an array of positive +// and negative numbers using bucket sort +#include +using namespace std; + +// Function to sort arr[] of size n using +// bucket sort +void bucketSort(vector &arr, int n) +{ + // 1) Create n empty buckets + vector b[n]; + + // 2) Put array elements in different + // buckets + for (int i=0; iNeg ; + vectorPos; + + // traverse array elements + for (int i=0; i