From d07be840253c18a415396058455fe69736f855ed Mon Sep 17 00:00:00 2001 From: Codes5761 <57105645+Codes5761@users.noreply.github.com> Date: Mon, 28 Oct 2019 21:59:31 +0530 Subject: [PATCH] Created bucket_sort.cpp Created bucket_sort.cpp --- bucket_sort.cpp | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 bucket_sort.cpp 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