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

Counting Sort

时间:2015-02-03 01:53:09      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:

1. Counting Sort doesn‘t work for negative number.

2. Counting Sort assumes that each element is SMALL INTEGER.

3. Time Complexity is O(Maximum value - Minimum value).

4. It is useful when the difference is not large

 

Algorithm:

1. Create an array of the size of the Maximun Value + 1.

2. Count each element.

3. Add up all elements.

4. Put them back to the result.

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

Counting Sort

标签:

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

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