//intput array A,output array result.   count array count .

//all the elements is in te range of 0~k.

//if k=O(n),the complexity is Θ(n)

//counting sort is stable

for(i=0;i<n;i++)result[i]=0;

for(i=1;i<=n;i++)count[a[i]]++;

for(i=1;i<=n;i++)count[i]+=count[i-1];

for(j=n;j>1;j--)

{

result[count[A[j]]]=A[j];

count[A[j]]--;

}

/radix sort

//对每一位数字进行排序,收集后,递归进行,直到全部排序完成

//bucket sort

//按区间分布bucket,bucket内部使用insert sort.

CLRS:sorting in linear time O(n)的更多相关文章

  1. (转)Awesome Courses

    Awesome Courses  Introduction There is a lot of hidden treasure lying within university pages scatte ...

  2. [Algorithm] 如何正确撸<算法导论>CLRS

    其实算法本身不难,第一遍可以只看伪代码和算法思路.如果想进一步理解的话,第三章那些标记法是非常重要的,就算要花费大量时间才能理解,也不要马马虎虎略过.因为以后的每一章,讲完算法就是这样的分析,精通的话 ...

  3. hdu.5195.DZY Loves Topological Sorting(topo排序 && 贪心)

    DZY Loves Topological Sorting Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 ...

  4. Chpater 10: Sorting

    Internal Sort: Bubble  O(n2) Selection O(n2) Insertion O(n2) Shell O(nlogn) Merge O(nlogn) Heap O(nl ...

  5. Topological Sorting

    Topological sorting/ ordering is a linear ordering of its vertices such that for every directed edge ...

  6. 排序算法(sorting)

    学习到的排序算法的总结,包括对COMP20003中排序部分进行总结,部分图片来自COMP20003 有部分内容来自http://www.cnblogs.com/eniac12/p/5329396.ht ...

  7. hdu 5195 DZY Loves Topological Sorting (拓扑排序+线段树)

    DZY Loves Topological Sorting Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 ...

  8. hdu 5195 DZY Loves Topological Sorting 线段树+拓扑排序

    DZY Loves Topological Sorting Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/sho ...

  9. hdu 5195 DZY Loves Topological Sorting BestCoder Round #35 1002 [ 拓扑排序 + 优先队列 || 线段树 ]

    传送门 DZY Loves Topological Sorting Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131 ...

随机推荐

  1. Filter 过滤器

    1. config in web.xml 2. @Component 3. @WebFilter (filterName="LoginFilter", url-patterns= ...

  2. java.lang.StackOverflowError: stack size 8MB

    java.lang.StackOverflowError: stack size 8MB at android.text.TextUtils.getChars(TextUtils.java:86) a ...

  3. Form_通过Zoom客制化跳转页面功能(案例)

    2012-09-08 Created By BaoXinjian

  4. RabbitMQ介绍1 - 由来

    RabbitMQ是一个异步消息通信中间件,用erlang语言开发,实现了AMQP(Advanced Message Queue )协议,是一个开源产品,官方网站:http://www.rabbitmq ...

  5. css针对(各大浏览器、各版本)调兼容

    ie6\ie7\firefox之下各自识别的CSS符号 #1 { color: #333; } /* firefox */ * html #1 { color: #666; } /* IE6 */ * ...

  6. 使用JS对form的内容验证失败后阻止提交 &&js校验表单后提交表单的三种方法总结

    1.form的两个事件 submit,提交表单,如果直接调用该函数,则直接提交表单 onSubmit,提交按钮点击时先触发,然后触发submit事件.如果不加控制的话,默认返回true,因此表单总能提 ...

  7. iPhone开发之UIScrollView初步

    来源:http://blog.csdn.net/htttw/article/details/7891396 iPhone开发之UIScrollView初步 今天我们初步介绍以一下iPhone开发中的U ...

  8. 文件下载(只需要简单的四步),Java中都通用

    我们就直接切入主题啦,文件下载只需要四步: 1.设置文件ContentType类型 2.设置文件头 3.通过response获取ServletOutputStream对象(out) 4.写到输出流(o ...

  9. 华为ICDcomm接口js测试

    1)获取坐席状态接口调用方法: “方法”------“坐席与班组” 中的 Phone.QueryAgentStatusEx(工号)如果该方法调用成功,那么坐席状态将会存入到属性: Phone.Agen ...

  10. tomcat7 内存溢出 java.lang.OutOfMemoryError: Java heap space

    在{tomcat7_home}bin/catalina.sh最上面添加: JAVA_OPTS="-server -Xms800m -Xmx800m -XX:PermSize=128M -XX ...