{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Bucket Sort

# Bucket Sort - int n,i,arr[max clrscr printf"Enter the...

This preview shows pages 1–3. Sign up to view the full content.

#include<stdio.h> #include<conio.h> /* RISHI AGARWAL             BUCKET SORT    ROLL NO 02    SE CMPN A */ #define max 10 void display(int a[],int n) {  int i;  printf("\nLIST\n");  for(i=0;i<n;i++)  printf("%d ",a[i]); } void bucketsort(int x[],int n) {  int i,j,y[10];  for(i=0;i<10;i++)  y[i]=0;  for(i=0;i<n;i++)  y[x[i]]++;  for(i=0,j=0;i<n,j<n;i++)  {   while(y[i]-->0)   {    x[j++]=i;   }

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
} } void main()
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { int n,i,arr[max]; clrscr(); printf("Enter the no of data:"); scanf("%d",&n); printf("Enter the nos"); for(i=0;i<n;i++) scanf("%d",&arr[i]); //Displaying List display(arr,n); //Bucket Sort bucketsort(arr,n); //Displaying Sorted List display(arr,n); getch(); } OUTPUT: Enter the no of data:5 Enter the nos5 4 3 2 1 LIST 5 4 3 2 1 LIST 1 2 3 4 5 */...
View Full Document

• Spring '07
• THAKUR
• #include, #define, RISHI AGARWAL, 02    SE CMPN, RISHI AGARWAL             BUCKET, int n,i,arr

{[ snackBarMessage ]}

### Page1 / 3

Bucket Sort - int n,i,arr[max clrscr printf"Enter the...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online