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 +#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