bucket sort
DESCRIPTION
codingTRANSCRIPT
Bucket SortBucket sort is possibly the simplest distribution sorting algorithm. The essentialrequirement is that the size of the universe from which the elements to be sorted aredrawn is a small, fixed constant, say m. or example, suppose that we are sorting elements drawn from , i.e., the set of integersin the interval!",m#$%. Bucket sort uses m counters. The counter keeps track of thenumber of occurrences of theelement of the universe. ollowing figureillustrates howthis is done. &n the figure above, the universalset is assumed to be '", $, . . ., (). Therefore, tencounters are required#one to keep track of the number of zeroes, one to keep track ofthe number of ones, and so on. * single pass through the data suffices to count all ofthe elements. +nce the counts have been determined, the sorted sequence is easilyobtained. ,.g., the sorted sequence contains no zeroes, two ones, one two, and so on.Example :-mcc .omputer .entre, /0 Burkit 1oad, T.2agar, .hennai#$3 45/4/6"7, (555"/35$" 43(/$0703.doc8age 1 of 2main9:'int i;int a!$"% < '/,$,5,$,7,(,4,6,7,5);clrscr9:;printf9=>n>n>n=:;BucketSort9a,$":;printf9=>n>n>n>n>n=:;for9in>n=:;for9i