Ask Question

Suppose that we perform Bucket Sort on an large array of n integers which are relatively uniformly distributed on a, b. i. After m iterations of bucket sorting, approximately how many elements will be in each bucket? ii. Suppose that after m iterations of bucket sorting on such a uniformly distributed array, we switch to an efficient sorting algorithm (such as MergeSort) to sort each bucket. What is the asymptotic running time of this algorithm, in terms of the array size n, the bucket numberk, and the number of bucketing steps m?

+3
Answers (1)
  1. 25 November, 01:07
    0
    Time complexity

    Explanation:

    If we assume that insertion in a bucket takes O (1) time then steps 1 and 2 of the above algorithm clearly take O (n) time. The O (1) is easily possible if we use a linked list to represent a bucket (In the following code, if C+ + vector is used for simplicity). Step 4 also takes O (n) time as there will be n items in all buckets.

    The main step to analyze is step 3. This step also takes O (n) time on average if all numbers are uniformly distributed.

    Sorted array is

    0.1234 0.3434 0.565 0.656 0.665 0.897
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Suppose that we perform Bucket Sort on an large array of n integers which are relatively uniformly distributed on a, b. i. After m ...” 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