摘要:
Good OverviewsGenerally speaking you're making a decision between fast read times (e.g. nested set) or fast write times (adjacency list). Usually you end up with a combination of the options below that best fit your needs. The following provides some in depth reading:One more Nested Intervals vs 阅读全文
随笔档案-2012年8月10日
蓄水池抽样 - Reservoir Sampling
2012-08-10 17:08 by coodoing, 1057 阅读, 收藏, 编辑
摘要:
蓄水池抽样一般用于海量数据不知道总数只能遍历一次随机抽样问题。第一部分:问题描述 问题起源于编程珠玑Column 12中的题目10,其描述如下: How could you select one of n objects at random, where you see the objects sequentially but you do not know the value of n beforehand? For concreteness, how would you read a text file, and select and print one random line, whe. 阅读全文
【转】求质数算法的N种境界- 试除法和初级筛法
2012-08-10 12:49 by coodoing, 621 阅读, 收藏, 编辑
摘要:
转帖:http://program-think.blogspot.com/2011/12/prime-algorithm-1.html★引子 前天,俺在《俺的招聘经验[4]:通过笔试答题能看出啥?》一文,以"求质数"作为例子,介绍了一些考察应聘者的经验。由于本文没有政治敏感内容,顺便就转贴到俺在CSDN的镜像博客。 昨天,某个CSDN网友在留言中写道:老实说,这个程序并不好写,除非你背过这段代码 如果只在纸上让别人写程序,很多人都会出错 但是如果给一台电脑,大多数人都会把这个程序调试正确 出这个题目没啥意义 只能让别人觉得你出题水平低 首先,... 阅读全文
[续]全排列的非递归实现
2012-08-10 09:04 by coodoing, 890 阅读, 收藏, 编辑
摘要:
前文提到过全排列的递归实现,这里在简单的介绍下全排列的非递归实现。 以6个数字的全排列为例说明,相当于用1,2,3,4,5,6 构造一个六位数,每一位上取一个数,这样一共有6!中方法。 很显然,这6!个数是有大小的,如果按从小到大排列,示意如下: 1 2 3 4 5 6 1 2 3 4 6 5 1 2 3 5 4 6 ………… ... 阅读全文