Skip to main content

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…

Following algorithm(s) can be used to sort nn in the range [1…n3][1\ldots n^3] in O(n)O(n) time

  1. A
    Heap sort
  2. B
    Quick sort
  3. C
    Merge sort
  4. D
    Radix sort
    Correct 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.