
Algorithms
fanbird2008
这个作者很懒,什么都没留下…
展开
-
Algorithm Intro - Bubble Sort
void bubble_sort(vector &v){ for(int i = 0; i for(int j = 1; j if(v[j - 1] int t = v[j -1]; v[j - 1] = v[j]; v[j] = t; }原创 2016-02-24 10:35:44 · 385 阅读 · 0 评论 -
Algorithm Intro - Merge Sort
void merge(vector &v, int left, int mid, int right){ int i = 0, tt[right - left + 1]; int nl = left, nm = mid + 1; if(left >= right) return; while(nl if(v[nl]原创 2016-02-24 10:35:20 · 354 阅读 · 0 评论 -
Algorithm intro - Select Sort
void select_sort(vector &v){ for(int i = 0; i int t = i; for(int j = i + 1; j if(v[j] } if(t != i) { int tt = v[i];原创 2016-02-24 10:34:19 · 472 阅读 · 0 评论 -
Algorithm Intro - Insert Sort
void insert_sort(vector &v){ for(int i = 1; i int p = i - 1, t = v[i]; while(p >= 0 && t v[p + 1] = v[p]; p--; } v[p + 1] = t;原创 2016-02-24 10:33:49 · 337 阅读 · 0 评论 -
Algorithm Intro - Quick Sort
int partition(vector<int> &v, int left, int right){ int pivot = v[left]; while(left < right){ while(left < right && v[right] > pivot) right--;...原创 2016-02-24 10:36:06 · 387 阅读 · 0 评论 -
Algorithm Intro - Count Sort
void count_sort(vector &v, vector&res){ int t = 0; vector r, c; r.assign(4096, 0); for(int i = 0; i c = r; res = r; for(int i = 0; i r[v[i]]++;原创 2016-02-24 10:36:34 · 401 阅读 · 0 评论 -
Algorithm Intro - Radix Sort
int get0to9(int n, int d){ while(n != 0 && d > 0) { n /= 10; d--; } return n % 10;}void count_sort0to9(vector &v, int index){ int count[10]; vector b = v;原创 2016-02-24 10:36:53 · 538 阅读 · 0 评论 -
string search and match
字符串匹配(String Matching)分类:算法学习 | 作者:酷~行天下 | 发表于2011/11/257条评论 4,614 views 字符串 T = abcabaabcabac,字符串 P = abaa,判断P是否是T的子串,就是字符串匹配问题了,T 叫做文本(Text) ,P 叫做模式(Pattern),所以正确描述是,找出所有在文本 T = abcabaabc转载 2012-12-16 17:55:44 · 690 阅读 · 0 评论 -
Longest Increasing Subsequence
出自http://www.felix021.com/blog/read.php?1587今天回顾WOJ1398,发现了这个当时没有理解透彻的算法。看了好久好久,现在终于想明白了。试着把它写下来,让自己更明白。最长递增子序列,Longest Increasing Subsequence 下面我们简记为 LIS。排序+LCS算法 以及 DP算法就忽略了,这两个太容易转载 2012-05-17 10:05:30 · 473 阅读 · 0 评论 -
HEAP-DELETE(A,i)操作将节点i中的项从堆中删去
题目:HEAP-DELETE(A,i)操作将节点i中的项从堆中删去。对含n个元素的最大堆,请给出时间为O(lgn)的HEAP-DELETE的实现。编程思路:我们可以用堆中最后一个元素a[heapSize]放到节点i 位置,然后将heapSize减一。然后就涉及到堆调整以保持堆的性质。调整的依据就是这最后一个元素a[heapSize]跟原来i节点的元素a[i]的相对大小,分三种情况:转载 2012-05-14 10:15:17 · 2683 阅读 · 0 评论 -
Manacher算法--O(n)回文子串算法
http://blog.youkuaiyun.com/ggggiqnypgjg/article/details/6645824O(n)回文子串算法注:转载的这篇文章,我发现下面那个源代码有点bug。。。在下一篇博客中改正了。。 这里,我介绍一下O(n)回文串处理的一种方法。Manacher算法.原文地址:http://zhuhongcheng.wordpress转载 2012-05-17 10:31:13 · 442 阅读 · 0 评论 -
字符串的Hash
出自http://www.felix021.com/blog/read.php?1596早上参加了腾讯的笔试,做完以后自我感觉良好,但是后来和sandy讨论了一下,发现还是挫了,因为没用上Hash。于是中午回去狠查了一些资料,看到了一点东西,充实了些。下载文件 (已下载 357 次)点击这里下载文件: Hash函数的设计优化-李羽修.doc.zip转载 2012-05-17 10:53:10 · 477 阅读 · 0 评论 -
Range Minimum Query and Lowest Common Ancestor
excerpt from http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=lowestCommonAncestor Introduction Notations Range Minimum Query (RMQ) Trivial algorithms for RMQ A so转载 2012-09-29 13:19:43 · 574 阅读 · 0 评论 -
Disjoint-set Data Structures
http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=disjointDataStructureIntroductionMany times the efficiency of an algorithm depends on the data structures used in the algorithm. A转载 2012-09-30 20:45:22 · 1553 阅读 · 0 评论 -
LINUX 硬链接与软链接的区别
本文试图清晰彻底的解释软链接和硬链接文件的区别 一 链接文件 链接有两种方式,软链接和硬链接。 1 软链接文件 软链接又叫符号链接,这个文件包含了另一个文件的路径名。可以是任意文件或目录,可以链接不同文件系统的文件。 **********链接文件甚至可以链接不存在的文件,这就产生一般称之为"断链"的问题(或曰“现象"),链接文件甚至可以循环链接自己。类似于编程语转载 2012-05-13 11:28:07 · 889 阅读 · 0 评论 -
Google presses algorithm, cloud advantage vs. Apple, rivals
http://www.zdnet.com/google-presses-algorithm-cloud-advantage-vs-apple-rivals-7000015452/Google presses algorithm, cloud advantage vs. Apple, rivalsSummary: Whether it's photo editing转载 2013-05-17 13:12:11 · 806 阅读 · 0 评论 -
MakeTree
#include #include char s1[27], s2[27];char result[27];int ind1 = 0, ind2 = 0, n = 0;int len = 0;int root;typedef struct _node { int lnode; int rnode;} node_t;node_t node[27];原创 2013-11-21 19:43:00 · 1556 阅读 · 1 评论 -
SLIK: 高扩展、低延时的键值存储索引实现(RAMCloud)
SLIK: 高扩展、低延时的键值存储索引实现(RAMCloud)2014 年 06 月 01 日写评论 作者麦子迈RAMCloud是新起的内存存储系统的典范,正好最近有一个蛋疼的翻译需求,就顺便将这篇SLIK实现的论文部分(最后评估部分见原文)译文贴在这里,原文SLIK: Scalable Low-Latency Indexes for a Key-转载 2014-07-02 15:25:29 · 3038 阅读 · 0 评论 -
Merge sort
#include void merge(int *arr, int l, int m, int r){ int i, tt[r - l + 1]; int cp = 0, lp = l, rp = m + 1; while(lp if(arr[lp] else tt[cp++] = ar原创 2013-11-21 21:01:55 · 860 阅读 · 0 评论 -
quick sort
#include const int N = 1024;int m, n, k;int u[N] = {0};void qsort(int nl, int nr){ int mid = 0; int nt, mn; if(nl mid = (nl + nr) / 2; mn = u[mid]; int i = nl, j = nr;原创 2013-11-21 19:39:23 · 726 阅读 · 0 评论 -
BigInt
const int N = 101;#include #define min(a, b) ((a) #define max(a, b) ((a) > (b) ? (a) : (b))using namespace std;const int NMAXBITS = 128;const int NBASE = 100000000;const int NSLEN = 8;原创 2013-11-21 19:41:18 · 1012 阅读 · 0 评论 -
BM string match algorithm
http://www-igm.univ-mlv.fr/~lecroq/string/node14.html转载 2012-11-06 11:58:36 · 435 阅读 · 0 评论