Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs) on “Bucket Sort (Uniform Keys)”.
1. How many comparisons will be made to sort the array arr={1, 5, 3, 8, 2} using bucket sort? Answer: d 2. What is the alternate name of bucket sort? 3. Which of the following non-comparison sort can also be considered as a comparison based sort? 4. Which of the following is not true about bucket sort? Answer: d 5. Which of the following don’t affect the time complexity of bucket sort? Answer: d 6. Bucket sort is most efficient in the case when __________ Answer: b 7. Bucket sort is a generalization of which of the following sort? Answer: b 8. What is the worst case time complexity of bucket sort (k = number of buckets)? Answer: c 9. What is the best time complexity of bucket sort (k= number of buckets)? Answer: a 10. Which of the following is not necessarily a stable sorting algorithm? Answer: a 11. Bucket sort is an in place sorting algorithm. Answer: b 12. What is the worst space complexity of bucket sort (k = number of buckets)? Answer: b
a) 5
b) 7
c) 9
d) 0
Clarification: As bucket sort is an example of a non-comparison sort so it is able to sort an array without making any comparison. So the answer should be 0.
a) group sort
b) radix sort
c) bin sort
d) uniform sort
Answer: c
Clarification: Bucket sort is also known as bin sort. It is an example of a non-comparison sort.
a) counting sort
b) MSD radix sot
c) bucket sort
d) pigeonhole sort
Answer: c
Clarification: Bucket sort can also be considered as a comparison based sort. It is because it can also be implemented with comparisons.
a) It is a non comparison based integer sort
b) It is a distribution sort
c) It can also be considered as comparison based sort
d) It is in place sorting algorithm
Clarification: Bucket sort is a non comparison based integer sort. It sorts the given data by distributing the array elements into a number of buckets. It is not an in place sorting technique.
a) algorithm implemented for sorting individual buckets
b) number of buckets used
c) distribution of input
d) input values
Clarification: Time complexity of bucket sort is affected by various factors. These include algorithm implemented for sorting individual buckets, number of buckets used and distribution of input. It doesnot depend on the input value. It can be either positive or negative or zero.
a) the input is non uniformly distributed
b) the input is uniformly distributed
c) the input is randomly distributed
d) the input range is large
Clarification: Bucket sort works by distributing the array elements into a number of buckets. So bucket sort is most efficient in the case when the input is uniformly distributed.
a) LSD radix sort
b) Pigeonhole sort
c) Counting sort
d) MSD radix sort
Clarification: Pigeonhole sort is a particular case of bucket sort. Bucket sort is also closely related to MSD radix sort.
a) O(n + k)
b) O(n.k)
c) O(n2)
d) O(n log n)
Clarification: Time complexity of bucket sort is O(n2) in the worst case. So if bucket sort does not get the inputs in the desired manner then it becomes very inefficient.
a) O(n + k)
b) O(n.k)
c) O(n2)
d) O(n log n)
Clarification: Time complexity of bucket sort is O(n+k). It performs better than any comparison based sort if there is a uniform input distribution.
a) bucket sort
b) counting sort
c) merge sort
d) pigeonhole sort
Clarification: Bucket sort is not necessarily a stable sorting algorithm. This is because its stability depends on the stability of the algorithm that we have used to sort the individual buckets.
a) True
b) False
Clarification: Bucket sort is not an in place sorting algorithm. It requires an auxiliary space of O(n k) in the worst case.
a) O(n + k)
b) O(n.k)
c) O(n2)
d) O(n log n)
Clarification: Worst case space complexity of bucket sort is O(n.k). So it is not an in place sorting algorithm.