Presentation on theme: "CAN IT BE CONSIDERED AN EFFECTIVE SORT METHOD? Answer maybe for small data sets but definitely not for large sets. Nevertheless it is stable."— Presentation transcript:
CAN IT BE CONSIDERED AN EFFECTIVE SORT METHOD? Answer maybe for small data sets but definitely not for large sets. Nevertheless it is stable
DEFINITION A bucket sort also known as a bin sort. Distributed to several buckets based on an interpolation. Each bucket is sorted and the bucket’s contents are concatenated or linked together in a series or chain. It is a non-comparison sorting that runs in linear time.
IMPLEMENTATION Use an auxiliary (used as a reserve) array of buckets. The range of values is divided into n equal parts, each of size k Be sure to examine contents of each bucket. Bucket one will contain values range (minimum to minimum + k-1) Bucket two will contain values range (minimum +k to minimum + 2k –1)
UNSORTED ARRAY A KEY N = 5 Values range from 1 -40
Allocation of the bins according to data range
Sorted Array B Note: The list of elements are concatenated
TIME ANALYSIS It is a O (n+k) operation. Reasons Each bin needs to examined first. Constant timework for each of the n data items or operations and the k unique keys.
CONCLUSION Bucket sort is a stable sort due to concatenation. Not recommended for large data sets Would be expensive just to implement due to large memory space. One would be better off using quicksort whose time is (n lg n) or heapsort whose run time is (n lg n).