UGC-NET Dec 2015 · Heap Sort & Non-Comparison Sorts

MCQ · 2 marks · Problem PROG-SORT-0008

If there are n integers to sort, each integer had d digits and each digit is in the set $\{1, 2, \dots, k\}$, radix sort can sort the numbers in
  1. A
    $O(d \: n \: k)$
  2. B
    $O(d n^k)$
  3. C
    $O(d+n)k)$
  4. D
    $O(d(n+k))$

Solve it on GATE DA practice →More Searching & Sorting Algorithms problems

Show the worked solutionRadix sort makes one pass per digit, \(d\) passes in total, and each pass is a stable counting sort over the \(k\) possible digit values, costing \(O(n+k)\).\[\boxed{T=d\cdot O(n+k)=O\big(d(n+k)\big)}\](A) \(O(dnk)\) would be the cost of a pass that is \(O(nk)\), not counting sort — incorrect; (B) is exponential in \(k\) — incorrect.Answer: D

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com