next up previous
Next: Bucket Sort Up: l4 Previous: Accuracy

Example

Show how n integers in the range 1 to $n^2$ can be sorted in O(n) time.



Use a Radix-n sort.

Each digit requires n symbols, and \(log_n n^2\) digits are needed (d=2, k=n).

T(n) = \(\Theta(2n \;+\; 2k)\)
= \(\Theta(2n \;+\; 2n)\)
= \(\Theta(n)\)


next up previous
Next: Bucket Sort Up: l4 Previous: Accuracy