All mock tests are FREE till 31 December — register to save your progress

Which of the following is best running time to n n2 − 1 sort integers in the range 0 to ?

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: B. O(n)

Explanation

Write each number as two base-n digits and radix sort: two counting-sort passes, O(n).

More Data Structures and Algorithms questions