Ask Question

You can sort a large array of integers that are in the range 1 to 100 by using an array count of 100 items to count the number of occurrences of each integer in the array. Fill in the details of this sorting algorithm, which is called a bucket sort, and write a C function that implements it. What is the order of the bucket sort

+4
Answers (1)
  1. 18 February, 02:18
    0
    See explaination

    Explanation:

    #include

    using namespace std;

    void bucketSort (int arr[], int size)

    {

    int count[101]={0};

    for (int i=0; i
    count[arr[i]]++;

    int k=0;

    for (int i=1; i<=100; i++)

    {

    while (count[i]>0)

    {

    arr[k++]=i;

    count[i]--;

    }

    }

    }

    int main ()

    {

    int arr[]={1,2,5,4,3,9,8,7,6};

    bucketSort (arr, 9);

    for (int i=0; i<9; i++) cout<
    cout<<"/n";

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “You can sort a large array of integers that are in the range 1 to 100 by using an array count of 100 items to count the number of ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers