Ask Question
1 September, 20:54

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

+2
Answers (1)
  1. 1 September, 23:41
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers