[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
RadixSort

(Computer science) Radix Sort

Is it possible to have a sort that runs in O(n) (linear) time? Yes, it is. Radix sort is the fastest sort in many situations, even faster than quick sort. On the negative side, it is sometimes limited in its applications, and it can require large amounts of memory at times.

It works on the same principle that most humans sort first. Given a list of names, One might first sort by the first letter, then the second letter, etc. Radix sort does this, only in reverse. First, a radix is chosen. For example, with a list of words, we might choose the letters of the words.

We have a list of linked lists, one for each of the possible letters in the word. We go through the list, starting at the last letter, and putting it in the appropriate list. We then collect them, in order, and put them back in the original list. They are now sorted by the last letter. This is repeated for each letter, until we get to the first letter. After collecting them the last time, the words will be in order.

One problem with this method is that it depends on a large radix. A small radix makes the length of the items to be sorted larger, thus making the length of the items more significant than the number. Larger radixes, however, require more memory. If a large amount of memory is available, this sort can be extremely fast.

last edited (November 6, 2006) by bilderbikkel, Number of views: 1424, Current Rev: 1

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.