From f7116e9a7b3aafc4ae04e4d3463ce53ec5b9ad9d Mon Sep 17 00:00:00 2001 From: nmk0462 <55138753+nmk0462@users.noreply.github.com> Date: Wed, 16 Oct 2019 23:10:19 +0530 Subject: [PATCH 1/3] Add files via upload --- radixsort.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 radixsort.c diff --git a/radixsort.c b/radixsort.c new file mode 100644 index 0000000..8410956 --- /dev/null +++ b/radixsort.c @@ -0,0 +1,85 @@ +#include +#include +int a[100],rem,larg,count=1,b[10],num,c[100],g,u=1,k,y,e1,f1,v,ym; +int n,i,e,f,t; +void main() +{ +printf("enter the no.of elements"); +scanf("%d",&n); +printf("enter the elements"); +for(i=0;ilarg) + { + larg=a[i]; + } +} +rem=larg/10; +while(rem>0) +{ + rem=rem/10; + count++; +} +while(u<=count) +{ +for(i=0;i<10;i++) +{ + b[i]=0; +} +for(i=0;i=0;i--) +{ + v=pow(10,u); + if(u==1) + { + g=a[i]%v; + k=b[g]; + c[k-1]=a[i]; + b[g]--; +} +else +{ + e1=pow(10,u); +f1=pow(10,u-1); +ym=a[i]%(e1); +g=ym/(f1); + k=b[g]; + c[k-1]=a[i]; + b[g]--; +} +} +for(i=0;i Date: Wed, 16 Oct 2019 23:12:08 +0530 Subject: [PATCH 2/3] Add files via upload --- bucketsort.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 bucketsort.c diff --git a/bucketsort.c b/bucketsort.c new file mode 100644 index 0000000..90d0a09 --- /dev/null +++ b/bucketsort.c @@ -0,0 +1,88 @@ +#include +#include +void main() +{ + int a[100],b[10][10],c[10]={0},n,i,count=1,rem,k,u=0,h=0,e=0,j=0,p,t,w,m; + printf("enter the no.of elements"); + scanf("%d",&n); + printf("enter the elements"); + for(i=0;i0) + { + count++; + rem=rem/10; + + } + if(count==1) + { + + b[0][h]=a[i]; + h++; + c[0]++; + } + if(count==2) + { + k=a[i]/10; + if(k==m) + { + e++; + } + else{e=0;} + b[k][e]=a[i]; + + c[k]++; + m=k; + } + count=1; + } +for(i=0;i<10;i++) +{if(c[i]==0) +{ + continue; +} +else +{ +p=i; + for(w=0;wb[p][j]) + { + t=b[p][w]; + b[p][w]=b[p][j]; + b[p][j]=t; + + } + } + + + } +} + +} + for(j=0;j<10;j++) + { + if(c[j]==0) + { + continue; + } + else{ + for(p=0;p Date: Thu, 31 Oct 2019 18:49:12 +0530 Subject: [PATCH 3/3] Add files via upload --- bucket sort.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 bucket sort.c diff --git a/bucket sort.c b/bucket sort.c new file mode 100644 index 0000000..635bfa0 --- /dev/null +++ b/bucket sort.c @@ -0,0 +1,59 @@ +#include +#include + +int main() +{ + int a[10][20],count[10]={0}; + int i,n,ele,x,y; + printf("enter the elements between 0 and 99\n"); + printf("enter the number of elements\n"); + scanf("%d",&n); + printf("enter %d elements\n",n); + for(i=0;ia[i][y+1]) + { + int z; + z=a[i][y]; + a[i][y]=a[i][y+1]; + a[i][y+1]=z; + } + } + } + } + } + printf("elements afetr sorting\n"); + for(i=0;i<10;i++) + { + if(count[i]==0) + { + continue; + } + else + { + int w; + for(w=0;w