Last updated 2004-06-28 by Roedy
Green ©1996-2004 Canadian Mind Products
Java definitions: 0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
You are here : home : Java Glossary : R words : RadixSort.
![]() | The Art Of Computer Programming | ||||||
| 0-201-48541-9 | |||||||
| Donald Knuth | |||||||
| Knuth's volumes 1, 2 and 3 are the reference works for standard algorithms. At his website he describes plans for volumes 4 and 5. | |||||||
| |||||||
The radix-distribution sort (which I call here simply RadixSort) is discussed at length in Knuth's Art of Computer Programming vol 3 #5.2.5, where he says that it was first published in 1929 in connection with tabulating machines, although it was probably known to the operators before that, and first described in the form included here in 1954. There is also a related radix-exchange sort.
RadixSort is stable, meaning it preserves existing order of equal keys. It works in linear time, unlike most other sorts. In other words, it does not bog down when you have large numbers of items to sort. The time per item to sort is constant. With other sorts, the time to sort per time increases with the number of items. Mathematicians would put it that most sorts run in O(N log(N)) or O(N2) time, where RadixSort runs in o(N) time.
Unfortunately, in this particular implementation, 16 bit characters count as two key slots, unless you can guarantee you never user the high order parts. In other words Unicode takes twice as long to sort as byte arrays.
The biggest drawback with RadixSort is that you have to write an unconventional compare routine.
The other drawback is RadixSort also uses somewhat more working storage than a traditional sort, because it copies references to the elements to sort back and forth between two arrays for each pass. Many other sorts make do with one array and some stack space.
Since all sorts can use the same Comparator interface, it is possible to experiment with various sorts to figure out which one works best for your situation.
home |
Canadian Mind Products | |||
| mindprod.com IP:[24.87.56.253] | ||||
| Your IP:[80.134.30.163] | ||||
| You are visitor number 2350. | ||||
| Please send errors, omissions and suggestions | ||||
| to improve this page to Roedy Green. | ||||
| You can get a fresh copy of this page from: | or possibly from your local J: drive mirror: | |||
| http://mindprod.com/jgloss/radixsort.html | J:\mindprod\jgloss\radixsort.html | |||