Following algorithm(s) can be used to sort in the range in time
GATE CSE 1992Algorithms › Sorting AlgorithmsVerified
GATE CSE 1992 PYQ: Following algorithm(s) can be used to sort n n n in the range [ 1 … n 3 ] [1\ldots n^3] [ 1 … n 3 ] in O ( n…
- AHeap sort
- BQuick sort
- CMerge sort
- DRadix sortCorrect answer
Answer
(D) Radix sort
Approach
Identify the sorting model: heap sort, quicksort, and merge sort are comparison-based and therefore cannot guarantee O(n) time. Radix sort is not comparison-based; with values bounded by $n^3$ and using base n, it needs only a constant number of digit passes, each taking O(n).
Only radix sort can sort n numbers in [1, $n^3]$ in O(n) time, by choosing base n so that the maximum number has a constant number of digits. Heap sort, quicksort, and merge sort are comparison-based and cannot beat the Ω(n log n) lower bound in general.
Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.