GATE Computer ScienceModerateGATE CS (PYQ pattern)

n keys, each an n-bit unsigned integer, are sorted by LSD radix sort that treats each key as digits of r = ⌊log₂ n⌋ bits (radix 2^r) and uses counting sort for every digit. What is the running time?

  1. A. Θ(n²/log n)
  2. B. Θ(n log n)
  3. C. Θ(n²)
  4. D. Θ(n)

Correct answer: A. Θ(n²/log n)

There are d = ⌈n/r⌉ = Θ(n/log n) digit passes, each a counting sort costing Θ(n + 2^r) = Θ(n + n) = Θ(n). Total Θ(n·n/log n) = Θ(n²/log n). Θ(n) would need a constant number of passes (keys polynomial in n), which n-bit keys are not.

More Algorithms questions

Exams that ask this topic