RadixSort : Java Glossary

go to home page R words local find full screen, hide local find menu Google search web for more information on this topic jump to foot of page translate this page with Babelfish by Roedy Green ©1996-2009 Canadian Mind Products
index page for letter ⇒ punctuation 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 (all)
RadixSort
is a sorting technique that mimics the old card sorters that worked column by column sending punched cards into different bins. I first heard of the idea from the late Tom Meikle who was a novice programmer when he independently discovered it back in 1968 when we implemented it for the venerable LGP-30. He called it "DigitSort". Only many years later after teaching it to scores of people did I learn it was already well known by the name RadixSort.

book cover recommend book⇒The Art of Computer Programming
 hardcover
ISBN13:978-0-201-48541-7impressioncounter
ISBN10:0-201-48541-9impressioncounter
publisher:Addison-Wesley
published:1998-10-15
by: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.
UK flag abe books.co.uk abe books.ca Canadian flag
UK flag amazon.co.uk. amazon.ca. Canadian flag
German flag abe books.de chapters.indigo.ca. Canadian flag
German flag amazon.de. abe books.com American flag
French flag abe books.fr amazon.com. American flag
French flag amazon.fr. barnes and noble.com American flag
Italian flag abe books.it powells.com American flag
Spanish flag iberlibro.com abe books anz Australian flag

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.

Advantages

In Java, RadixSort is faster than either QuickSort or HeapSort in the benchmarks I ran. For small numbers of items, almost any sorting algorithm will work just fine. There is rarely any reason to use anything but the built-in tournament sort, unless the sort is too big to fit in RAM, where you need something like opt-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(n²) time, where RadixSort runs in O(n) time.

Drawbacks

Tuning

If you want a high speed version of RadixSort for a particular application, you will have to inline the comparison delegate code since delegate.getKeyByteAt, is where it chews up all the CPU time.

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.

Variants

There are other ways to implement the same basic algorithm by chaining the objects to be sorted together, but that tends to be inefficient in Java since you need separate glue objects to do the linking unless the items to be sorted themselves implement some chaining interface.

CMP homejump to top
CMP logo
feedback Please email your feedback for publication, errors, omissions, broken/redirected link reports
and suggestions to improve this page to Roedy Green : feedback email
made with CSS
HTML Checked!
ICRA ratings logo
mindprod.com IP:[65.110.21.43]
Your face IP:[38.103.63.58]
You are visitor number 17,057.
You can get a fresh copy of this page from: or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror)
http://mindprod.com/jgloss/radixsort.html J:\mindprod\jgloss\radixsort.html