From 4d8185f83eae1150e7c87affd7374d1997f09276 Mon Sep 17 00:00:00 2001 From: Sayantika Banik Date: Fri, 29 Sep 2017 07:55:30 +0530 Subject: [PATCH] bucket sort code added --- Sorting/bucketSort.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Sorting/bucketSort.cpp 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