View Single Post
  #7  
Old 11-14-2007, 05:31 PM
DoTheMath DoTheMath is offline
Member
 
Join Date: Jul 2006
Location: At my computer
Posts: 61
Default Re: Best Sorting Algorithm For Large Numbers

[ QUOTE ]
If you had to sort a list of random numbers between 0 and 9999999999999999 (16 digits), what is the fastest algorithm?

[/ QUOTE ]
The relative speeds of sort algorithms themselves are not generally affected by the size of the individual data values. The sorting algorithms are data type independent. The characteristics of the data that most affect the choice of fastest algorithm are the number of items to be sorted and the degree to which they are already sorted. Another factors is whether the sort is to be done using the memory that stores the data or whether more memory or memory structures are available to be used as an intermediate or replacement storage area. Another factor that might affect the choice of algorithms is the distribution of data within the range.

The issue of number size is more likely to affect the comparison algorithm used by the sort and the data structure of your implementation.

[ QUOTE ]

If the maximum number changes even higher to something that does not fit in a long data type, does the answer change?

[/ QUOTE ]
As long as you are still sorting numbers, generally the answer is no. If the numbers are very large integers that do not fit into a numeric data type supported by your implemention environment, you may find yourself representing your data as a string of (often character) values. This might lead one to consider a LSD radix sort, but I don't believe that this would likely be faster than a comparison sort.

As oe39 said, read wiki, but I would suggest starting with the Sorting Algorithms page, or read Knuth.
Reply With Quote