Bucket Sort - { int n,i,arr[max]; clrscr();...

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

View Full Document Right Arrow Icon
#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;   }
Background image of page 1

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

View Full DocumentRight Arrow Icon
 } } void main()
Background image of page 2
Background image of page 3
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(&quot;Enter the no of data:&quot;); scanf(&quot;%d&quot;,&amp;n); printf(&quot;Enter the nos&quot;); for(i=0;i&lt;n;i++) scanf(&quot;%d&quot;,&amp;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

This note was uploaded on 10/25/2010 for the course CMPN SEM4 taught by Professor Thakur during the Spring '07 term at University of Mumbai.

Page1 / 3

Bucket Sort - { int n,i,arr[max]; clrscr();...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online