Bucket Sort in C and C++

Here you will get program for bucket sort in C and C++.

In bucket sort algorithm the array elements are distributed into a number of buckets. Then each bucket sorted individually either using any other sorting algorithm or by recursively applying bucket sort.

Take example shown in below image.

Bucket Sort

Elements are distributed among buckets

Bucket Sort

Then, elements are sorted within each bucket

Below is the program to implement this algorithm. In this program it is assumed that the array elements are between 0 to 10.

Program for Bucket Sort in C

Program for Bucket Sort in C++

Output

Before sorting:
3 6 5 1 8 4 3 1

After sorting:
1 1 3 3 4 5 6 8

3 thoughts on “Bucket Sort in C and C++

  1. RAHUL KUMAR

    there is mistake in c++ program which is value is SIZE is not given

    Reply
  2. birjesh

    ohh…hello it’s not bucket sort ,your coding is almost like counting sort……….u r making a fool of us …..first learn what bucket sort is okk

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *