From 363c371c2c895ef8abc35395b4a9493ad6c405f0 Mon Sep 17 00:00:00 2001 From: Raman Kapri <40718728+Raman1309@users.noreply.github.com> Date: Sun, 27 Oct 2019 22:35:41 +0530 Subject: [PATCH] BucketSort.cpp This solves #2 --- BucketSort.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 BucketSort.cpp diff --git a/BucketSort.cpp b/BucketSort.cpp new file mode 100644 index 0000000..9579f51 --- /dev/null +++ b/BucketSort.cpp @@ -0,0 +1,48 @@ +#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>n; + + float arr[n]; + cout<<"\n Enter elements in array : "; + for(int i=0;i>arr[i]; + + bucketSort(arr, n); + + cout << "Sorted array is \n"; + for (int i=0; i