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 ...
随机推荐
- NeHe OpenGL教程 第六课:纹理映射
转自[翻译]NeHe OpenGL 教程 前言 声明,此 NeHe OpenGL教程系列文章由51博客yarin翻译(2010-08-19),本博客为转载并稍加整理与修改.对NeHe的OpenGL管线 ...
- Python分布式爬虫原理
转载 permike 原文 Python分布式爬虫原理 首先,我们先来看看,如果是人正常的行为,是如何获取网页内容的. (1)打开浏览器,输入URL,打开源网页 (2)选取我们想要的内容,包括标题,作 ...
- [ Redis ] Redis 未授权访问漏洞被利用,服务器登陆不上
一.缘由: 突然有一天某台服务器远程登陆不上,试了好几个人的账号都行,顿时慌了,感觉服务器被黑.在终于找到一个还在登陆状态的同事后,经查看/ect/passwd 和/etc/passwd-异常,文件中 ...
- Hibernae 的延迟加载
http://blog.csdn.net/xc635960736/article/details/7049863 Hibernae 的延迟加载 Hibernae 的延迟加载是一个非常常用的技术,实 ...
- 启动httpd服务:SSLCertificateFile: file '/var/www/miq/vmdb/certs/server.cer' does not exist or is empty
启动httpd服务,失败: [root@test vmdb]# service httpd restart Stopping httpd: [FAILED] Starting httpd: Synta ...
- JDBC常用代码
try { //加载驱动 Class.forName("com.mysql.jdbc.Driver"); String url="jdbc:mysql://127.0.0 ...
- Mongo 备份 还原
表还原 mongorestore --collection Inquiry0315 -d Estate --drop --dir D:/backup/20150731/Estate/Inquiry.b ...
- [ActionScript 3.0] AS3.0 给flash事件传递参数的方法
有时我们想要给flash内置的事件(比如MouseEvent)传递参数,这时我们可以用到下面的方法. import flash.events.MouseEvent; mc.addEventListen ...
- angularJs中的隐藏和显示
<!DOCTYPE html> <html ng-app="a2_12"> <head> <meta charset="utf- ...
- tarjan 边双连通分量 对点进行分组 每组点都在一个双连通分量里边
int dfn[N],low[N],id[N],s[N],p,num,t,son[N];//dfn记录dfs时间戳//low代表当前点到达的最小时间戳,id对点进行分组编号.num是时间戳//s临时存 ...