What do bucket sort radix sort and counting sort have in com
What do bucket sort, radix sort, and counting sort have in common?
They all have the same time complexities no matter what case.
They are comparison sorting algorithms.
They are non-comparison sorting algorithms.
| a. | They all have the same time complexities no matter what case. | |
| b. | They are comparison sorting algorithms. | |
| c. | They are non-comparison sorting algorithms. |
Solution
c. They are non-comparison sorting algorithms.
It means keys are not compared with each other.
Radix Sort: O(dn) (d invocations of Bucket Sort) with space O(k) (will be seen later)
Bucket Sort: O(n) with space O(n)
Counting Sort: O(n) with space O(k) where each element is an integer and in the range of 0 to k-1
