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?
- A. Θ(n²/log n)
- B. Θ(n log n)
- C. Θ(n²)
- 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
- Two sorted lists of 5 and 7 distinct keys are to be merged into one sorted list by comparisons. What does the decision-tree…
- Cocktail-shaker sort is applied to [5, 1, 4, 2, 8, 0, 3]: sweeps alternate left-to-right and right-to-left over the unsorted part (each…
- In randomised quicksort on n = 10 distinct keys (pivot chosen uniformly, so two keys with ranks i < j are compared with probability 2/(j −…
- Multiplying two n × n matrices classically costs n³ multiplications and n²(n − 1) additions. One level of Strassen (7 products of n/2 ×…
- Karatsuba multiplies two n-digit numbers (n = 2^k) with 3 half-size products, recursing down to 1-digit numbers; the classical method uses…
- Let T(1) = 1 and T(n) = (1 + 1/n)·T(n − 1) + 1 for n ≥ 2. Which is the tight bound on T(n)?