From 7557c9629ecf5a6866334278c5c1f727af8ae52d Mon Sep 17 00:00:00 2001 From: pkdism Date: Tue, 22 Nov 2016 10:51:07 +0530 Subject: [PATCH] Add Radix Sort --- Radix Sort.cpp | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Radix Sort.cpp diff --git a/Radix Sort.cpp b/Radix Sort.cpp new file mode 100644 index 000000000..eb3f12a57 --- /dev/null +++ b/Radix Sort.cpp @@ -0,0 +1,60 @@ +#include +#include +#include +#include +using namespace std; +void radixsort(int a[],int n){ + int count[10]; + int output[n]; + memset(output,0,sizeof(output)); + memset(count,0,sizeof(count)); + int max = 0; + for (int i = 0; i < n; ++i) + { + if (a[i]>max) + { + max = a[i]; + } + } + int maxdigits = 0; + while(max){ + maxdigits++; + max/=10; + } + for(int j=0;j