摘要: KMP算法class KMP{public: vector create_prefix_function(string s) { vector next(s.size(), 0); next[0] = 0; int k = 0; f... 阅读全文
posted @ 2014-09-06 16:19 liuzhijiang123 阅读(102) 评论(0) 推荐(0) 编辑
摘要: 对序列 {a, b, c},每一个元素都比后面的小,按照字典序列,固定a之后,a比bc都小,c比b大,它的下一个序列即为{a, c, b},而{a, c, b}的上一个序列即为{a, b, c},同理可以推出所有的六个序列为:{a, b, c}、{a, c, b}、{b, a, c}、{b, c, ... 阅读全文
posted @ 2014-08-05 09:27 liuzhijiang123 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 编辑距离概念描述:编辑距离,又称Levenshtein距离,是指两个字串之间,由一个转成另一个所需的最少编辑操作次数。许可的编辑操作包括将一个字符替换成另一个字符,插入一个字符,删除一个字符。例如将kitten一字转成sitting:sitten (k→s)sittin (e→i)sitting (... 阅读全文
posted @ 2014-07-31 17:13 liuzhijiang123 阅读(194) 评论(0) 推荐(0) 编辑
摘要: 红黑树数据结构#ifndef __RED_BLACK_TREE_H#define __RED_BLACK_TREE_H#define RED 1#define BLACK 0typedef struct Red_Black_Node{ int id; int color; int ... 阅读全文
posted @ 2014-07-31 11:33 liuzhijiang123 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 递归#include #include #include #define NUM 4int total = 0;void print_board(int *board){ printf("\n"); for (int i = 0; i #include #define NUM 4int ... 阅读全文
posted @ 2014-07-30 17:12 liuzhijiang123 阅读(281) 评论(0) 推荐(0) 编辑
摘要: 字典树,又称单词查找树,Trie树,是一种树形结构,典型应用是用于统计,排序和保存大量的字符串,所以经常被搜索引擎系统用于文本词频统计。它的优点是:利用字符串的公共前缀来节约存储空间,最大限度的减少无谓的字符串比较,查询效率比哈希表高。它有三个基本性质,根节点不包含字符,除根节点外每一个节点都只包含... 阅读全文
posted @ 2014-07-30 11:19 liuzhijiang123 阅读(252) 评论(0) 推荐(0) 编辑
摘要: ?匹配任意一个字符,*匹配任务多个字符(包括0)#include #include int match(const char *src, const char *pattern){ if (src == NULL || pattern == NULL) { return 0... 阅读全文
posted @ 2014-07-30 10:15 liuzhijiang123 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 11 using std::cout; 12 using... 阅读全文
posted @ 2014-07-25 16:33 liuzhijiang123 阅读(191) 评论(0) 推荐(0) 编辑
摘要: C函数调用机制在Linux内核程序boot/head.s执行完基本初始化操作之后,就会跳转去执行init/main.c程序。那么head.s程序是如何把执行控制转交给init/main.c程序的呢?即汇编程序是如何调用执行C语言程序的?这里我们首先描述一下C函数的调用机制、控制权传递方式,然后说明h... 阅读全文
posted @ 2014-07-21 19:53 liuzhijiang123 阅读(740) 评论(0) 推荐(0) 编辑
摘要: 问题描述:Time Limit: 10000msCase Time Limit: 1000msMemory Limit: 256MBDescriptionConsider a string set that each of them consists of {0, 1} only. All stri... 阅读全文
posted @ 2014-06-23 19:26 liuzhijiang123 阅读(191) 评论(0) 推荐(0) 编辑