Radix sort

来源:互联网 发布:tag在vb什么意思 编辑:程序博客网 时间:2024/05/22 02:30

Radix sort will not consider the value of the element, but the value of the digit of the element. For example, when comparing 345, 673, 122,  the radix sort first consider the third (last) digits and compare, so the result will be 

122

673

345

Then radix sort will compare the second digit, and the result after comparison is

122

345

673

 

Finally, it will compare the first digit, and the result is

122

345

673

 

The radix sort will use counting sort to sort the digits in the array, the reason why we use counting sort other than quick sort, merge sort is that counting sort will not disturb the sequence in the original array. For example, if 234 is in front of 235, after sorting the second digit, the order will be 234, 235, it will not be 235, 234.

 

 

 

Reference:

http://www.cnblogs.com/sun/archive/2008/06/26/1230095.html