CLRS:sorting in linear time O(n)
//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)的更多相关文章
- (转)Awesome Courses
Awesome Courses Introduction There is a lot of hidden treasure lying within university pages scatte ...
- [Algorithm] 如何正确撸<算法导论>CLRS
其实算法本身不难,第一遍可以只看伪代码和算法思路.如果想进一步理解的话,第三章那些标记法是非常重要的,就算要花费大量时间才能理解,也不要马马虎虎略过.因为以后的每一章,讲完算法就是这样的分析,精通的话 ...
- hdu.5195.DZY Loves Topological Sorting(topo排序 && 贪心)
DZY Loves Topological Sorting Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 ...
- Chpater 10: Sorting
Internal Sort: Bubble O(n2) Selection O(n2) Insertion O(n2) Shell O(nlogn) Merge O(nlogn) Heap O(nl ...
- Topological Sorting
Topological sorting/ ordering is a linear ordering of its vertices such that for every directed edge ...
- 排序算法(sorting)
学习到的排序算法的总结,包括对COMP20003中排序部分进行总结,部分图片来自COMP20003 有部分内容来自http://www.cnblogs.com/eniac12/p/5329396.ht ...
- hdu 5195 DZY Loves Topological Sorting (拓扑排序+线段树)
DZY Loves Topological Sorting Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 ...
- hdu 5195 DZY Loves Topological Sorting 线段树+拓扑排序
DZY Loves Topological Sorting Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/sho ...
- 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 ...
随机推荐
- Uvision5不能进行软件仿真
Uvision5不能进行软件仿真不能进行软件仿真,报错: error 65: access violation at 0x40021000 : no 'read' permission(软件仿真出错) ...
- $.ajax()中dataType
$.ajax()中dataType的默认值为TEXT,如果没有指明json,而返回来的数据又就是json格式,则无法显示.!!
- 树莓派学习:源码方式安装opencv
1:下载若干依赖项: 更新软件源:sudo apt-get update/upgrade; 依次安装一下依赖项: sudo apt-get install build-essential su ...
- MongoDB基本命令的使用
成功启动MongoDB后,再打开一个命令行窗口输入mongo,就可以进行数据库的一些操作. 输入help可以看到基本操作命令: show dbs:显示数据库列表 show collections:显示 ...
- JAVA集合小结
下面是我自己画的,关系画得没上面好,但我自己看着清楚些 还有一张下载来的: 有序否 允许元素重复否 Collection 否 是 List 是 是 Set AbstractSet 否 否 Hash ...
- 玄机论坛Socket类库源码 当前版本 2.6.3 更新日期:10-09/2015 z
http://bbs.msdn5.com/thread-27-1-1.html 本类库采用TcpLister,TcpClient高度封装, 采用NetworkStream进行异步模式读取数据. 采用S ...
- CentOS7 MongoDB安裝
查看MongoDB的最新版官方下载地址: https://www.mongodb.com/download-center#community 使用wget命令下载安装包 ? 1 wget https: ...
- springmvc使用pojo和servlet原生api作为参数
一.Pojo作为参数: 实体: package com.hy.springmvc.entities; public class User { private String username; priv ...
- Html5中的跨页面消息传输
1.如果要接受从其他的窗口那里发过来的消息,就必须对窗口对象的message事件进行监控. window.addEventListener("message",function() ...
- 理解EnterCriticalSection 临界区
通俗解释就像上厕所: 门锁了,就等着,等到别人出来了,进去锁上,然后该干什么干什么,干完了,把门打开 门没锁,就进去,锁上,然后该干什么干什么,干完了,把门打开 ------------------- ...