随笔分类 -  算法

摘要: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 阅读(104) 评论(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 阅读(152) 评论(0) 推荐(0)
摘要:编辑距离概念描述:编辑距离,又称Levenshtein距离,是指两个字串之间,由一个转成另一个所需的最少编辑操作次数。许可的编辑操作包括将一个字符替换成另一个字符,插入一个字符,删除一个字符。例如将kitten一字转成sitting:sitten (k→s)sittin (e→i)sitting (... 阅读全文
posted @ 2014-07-31 17:13 liuzhijiang123 阅读(203) 评论(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 阅读(128) 评论(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 阅读(296) 评论(0) 推荐(0)
摘要:字典树,又称单词查找树,Trie树,是一种树形结构,典型应用是用于统计,排序和保存大量的字符串,所以经常被搜索引擎系统用于文本词频统计。它的优点是:利用字符串的公共前缀来节约存储空间,最大限度的减少无谓的字符串比较,查询效率比哈希表高。它有三个基本性质,根节点不包含字符,除根节点外每一个节点都只包含... 阅读全文
posted @ 2014-07-30 11:19 liuzhijiang123 阅读(273) 评论(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 阅读(132) 评论(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 阅读(196) 评论(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 阅读(202) 评论(0) 推荐(0)
摘要:SMO算法是SVM的重要部分.分类函数记为\(\vec{u} = (\vec{w},\vec{x}) - b\)SMO算法分为两个部分,第一部分是求\[\Psi(\vec{\alpha}) = \frac{1}{2}\sum_{i = 1}^{N}\sum_{j = 1}^{N}y_{i}y_{j}... 阅读全文
posted @ 2014-04-12 14:40 liuzhijiang123 阅读(702) 评论(0) 推荐(0)
摘要:题目: 求 \(\log_{10}x\)解法: 因为 \(10^y = x\), 所以 \(y = \log_{10}x\), 那么 \(y\) 为一个实数, 记为 \[y = n + 0.d_1d_2d_3\ldots d_k \ldots\]即有 \(10^{n + 0.d_1d_2d_3\ld... 阅读全文
posted @ 2013-12-25 10:45 liuzhijiang123 阅读(1259) 评论(0) 推荐(0)