随笔分类 -  Optimization and Algorithm

摘要:http://blog.csdn.net/kittyjie/article/details/4386742http://blog.csdn.net/szkbsgy/article/details/6420113http://www.cnblogs.com/YOUEN/archive/2012/02/02/2336115.htmlhttp://blog.csdn.net/njzhiyuan/article/details/4369588http://blog.csdn.net/xufei96/article/details/5984647 阅读全文
posted @ 2012-04-24 18:52 yarpee
摘要:1.KMP算法的核心思想是利用已经得到的部分匹配信息来进行后面的匹配过程KMP算法,即Knuth-Morris-Pratt算法,是一种典型的基于前缀的搜索的字符串匹配算法。(1)next[0]= -1 意义:任何串的第一个字符的模式值规定为-1。(2)next[j]= -1 意义:模式串T中下标为j的字符,如果与首字符相同,且j的前面的1—k个字符与开头的1—k个字符不等(或者相等但T[k]==T[j])(1≤k<j)。如:T=”abCabCad” 则 next[6]=-1,因T[3]=T[6](3)next[j]=k 意义:模式串T中下标为j的字符,如果j的前面k个字符与开头的k个字符 阅读全文
posted @ 2012-04-24 16:46 yarpee
摘要:编写代码时应当注意避免滥用系统调用减少fread与read系统调用的次数#include <stdio.h>#include <stdlib.h>#include <sys/types.h>#include <sys/stat.h>#include <unistd.h>#include <sys/mman.h>void main(){ int fd = open("test.file",o); struct stat statbuf; char *start; char buf[2] = {0}; in 阅读全文
posted @ 2012-04-21 17:10 yarpee
摘要:http://blog.csdn.net/bresponse/article/details/6905904http://blog.csdn.net/bresponse/article/details/6905933平衡二叉树(Balanced Binary Tree):它是一棵空树或它的左右两个子树的高度差的绝对值不超过1,并且左右两个子树都是一颗平衡二叉树。红黑树,能保证在最坏情况下,基本的动态几何操作的时间均为O(lgn).红黑树上每个结点内含五个域,color,key,left,right,p。如果相应的指针域没有,则设为NIL。一般的,红黑树,满足以下性质,即只有满足以下全部性质的树 阅读全文
posted @ 2011-12-23 14:48 yarpee