Bucket Sort

  • Bucket Sort is a sorting technique that sorts the elements by first dividing the elements into several groups called buckets. 
  • The elements inside each bucket are sorted using any of the suitable sorting algorithms or recursively calling the same algorithm.
  • Several buckets are created. Each bucket is filled with a specific range of elements. 
  • The elements inside the bucket are sorted using any other algorithm. Finally, the elements of the bucket are gathered to get the sorted array.
  • The process of bucket sort can be understood as a scatter-gather approach

  • The elements are first scattered into buckets then the elements of buckets are sorted. Finally, the elements are gathered in order.


Time Complexities:

  • Worst Case Complexity: O(n2)
    If we want to sort in ascending order and the array is in descending order then, the worst case occurs.

  • Best Case Complexity: O(n+k)
    It occurs when the array is already sorted

  • Average Case Complexity: O(n+k)
    It occurs when the elements of the array are in jumbled order (neither ascending nor descending)

Post a Comment

0 Comments