Sorting in Linear Time
There are several sorting
methods that take linear time
(see Chapter 9 in CLR)
• Counting Sort
– sorts integers from a small
range: [0..k] where k = O(n)
• Radix Sort
– the method used by the old
card-sorters
– sorting time O(dn) where d
is the number of “digits”
• How do these methods get
around the W(n log n) lower
bound?
– They don’t use comparisons
• What sorting method works
best?
– QuickSort is best general-
purpose sort
– Counting Sort or Radix Sort
can be best for some kinds
of data
CS409 - Spring 2000
5