2011年6月1日

摘要: counting sort: for A[1,...,n], given that for any i, 0<=i<=n, then c<=A[i]<=d. let m = d-c+1, create an array B[1, ..., m]. each item B[j] means how many items in A are less or equal to c+j-1:for i <- 1 to n B[A[i]]++for j <- 2 to m B[j] = B[j] + B[j-1] then it's easy to constr 阅读全文
posted @ 2011-06-01 11:35 freestyleking 阅读(589) 评论(0) 推荐(0) 编辑
摘要: 又看了一遍more effective c++, 注意到以前没怎么记住的virtual clone技术。classBase{public:virtualBase*clone();};classImpl1{public:virtualImpl1*clone(){returnnewImpl1(*this);}};classImpl2{public:virtualImpl2*clone(){returnnewImpl2(*this;);}};初一看没什么特别的。clone只是调用了拷贝构造函数。确实,在没有类层次结构的情况下,一个这样的clone()并不会比直接写拷贝构造有用。奇特的是, 这里3个. 阅读全文
posted @ 2011-06-01 11:33 freestyleking 阅读(3582) 评论(0) 推荐(2) 编辑

2010年7月22日

摘要: problem 7.1 and 7.5才知道快速排序也有不少版本。 版本不同之处在于partition的算法。以前大学学的是使用Median-of-3 +Hoare partition(左右交换法)。导论上首先给出的算法就叫左右界限推算法吧。基本就是选取目标元素(最后一个),然后从左到右和目标值比较,半段属于左边还是右边(用两个索引值表示左右两个集合的界限)简单实现一下两种算法:c++: /Fil... 阅读全文
posted @ 2010-07-22 11:50 freestyleking 阅读(957) 评论(0) 推荐(0) 编辑

2010年7月14日

摘要: build a max heap, use it to do heap sort and resolve problem6.1there are two ways to build a max heap. 1. for each node from 0 to size/2, do maxheapify. maxheapfy is to assume a node's left subtree a... 阅读全文
posted @ 2010-07-14 21:01 freestyleking 阅读(362) 评论(0) 推荐(0) 编辑

2010年7月13日

摘要: exercises:1.Show that the solution of T (n) = T (⌈n/2⌉) + 1 is O(lg n).let T(n/2) <= c*lg(n/2),thenT(n) = T(n/2) + 1 <= c*lg(n/2) + 1 = c*lgn -c + 1 <= c*lgn, as long as c >=12... 阅读全文
posted @ 2010-07-13 20:19 freestyleking 阅读(1113) 评论(0) 推荐(0) 编辑

2010年5月24日

摘要: 想知道服务器上有多少个超过1秒慢连接,想知道多少TCP连接失败吗?yahoo开源的这个工具对系统调优、性能监控很有帮助 http://sourceforge.net/projects/yconalyzer/研究一下用法 阅读全文
posted @ 2010-05-24 15:51 freestyleking 阅读(171) 评论(0) 推荐(0) 编辑
摘要: cpu affinity原帖地址:http://www.hiadmin.com/?p=1452常常感觉系统资源不够用,一台机子上跑了不下3个比较重要的服务,但是每天我们还要在上面进行个备份压缩等处理,网络长时间传输,这在就很影响本就不够用的系统资源; 这个时候我们就可以把一些不太重要的比如copy/备份/同步等工作限定在一颗cpu上,或者是多核的cpu的一颗核心上进行处理,虽然这不一定是最有效的方... 阅读全文
posted @ 2010-05-24 15:44 freestyleking 阅读(222) 评论(0) 推荐(0) 编辑

2010年3月31日

摘要: 1。 mount iso的命令:mount -t iso9660 -o loop xxx.iso destination注意mount出来的destination dir必须存在。而且mount成功后是read-only的,需要把里面的内容cp出来才行。2. 快速查看系统发行版的命令:cat /et... 阅读全文
posted @ 2010-03-31 15:23 freestyleking 阅读(159) 评论(0) 推荐(0) 编辑

2009年7月23日

摘要: Normal 0 false false false MicrosoftInternetExplorer4 其实大多是一些摘录。第6章以后的内容就有点看不下去了,功力太差。2.1 Default Constructor Construction Consider the case of each constructor defined for a class containing one or m... 阅读全文
posted @ 2009-07-23 16:34 freestyleking 阅读(290) 评论(0) 推荐(0) 编辑
摘要: 最近在看代码大全。感觉有些是空谈般的说教,不过大部分内容还是很有借鉴意义的。摘录一些觉得比较有用的内容,当作是学习笔记吧,还不完全,慢慢添加。 Normal 0 false false false MicrosoftInternetExplorer4 6抽象数据类型 6.1 ADT a. 把底层数据类型抽象为ADT,尽量避免在程序中大量出现底层数据类型的操作。 例如:currentFont.... 阅读全文
posted @ 2009-07-23 16:16 freestyleking 阅读(310) 评论(0) 推荐(0) 编辑

导航