码迷,mamicode.com
首页 > 其他好文 > 详细

Radix Sort

时间:2015-02-03 06:56:27      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:

1. When we are sorting the numbers we will first find the number of digits in the biggest number.

2. If there are N digits in the biggest number then we will need to perform N number of pass.

3. We will pad the remaining numbers with leading zeros so they all have N digits.

4. Then we will take 10 buckets labeled 0 to 9 and sort the numbers.

 

Time Complexity : O(N*n)  where N is the digits of the biggest number, and n is the length of the array.

Space Complexity: O(1), it will take 10 buckets.

https://www.youtube.com/watch?v=YXFI4osELGU

Radix Sort

标签:

原文地址:http://www.cnblogs.com/winscoder/p/4269056.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!