<<算法导论>>
文章平均质量分 74
MiniSheep_CS
编程者如上帝,可以创造万物。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
算法导论(LCS最长公共子序列)
真动态规划版(自底而下): #include using namespace std; const int maxn = 10001; int m,n; char b[maxn][maxn]; //回溯时保存路径 int c[maxn][maxn]; //最长子序列 void LCS(char *x,char *y) { int i,j; for(i=0;i<=m;i++)原创 2015-04-13 09:40:42 · 481 阅读 · 0 评论 -
最大堆实现堆排序
#include using namespace std; const int maxn = 100001; int Parent(int i) { return i / 2; } int Left(int i) { return 2 * i; } int Right(int i) { return 2 * i + 1; } void Max_heapify(int *a,int原创 2015-05-07 16:13:11 · 374 阅读 · 0 评论 -
算法导论-KMP模版
#include #include #include using namespace std; const int maxn = 10001; int next[maxn]; void Compute(char *p) //匹配串和自己的next值 { int m = strlen(p); memset(next,0,sizeof(next)); next[1] =原创 2015-05-18 19:12:02 · 457 阅读 · 0 评论 -
DFS遍历图代码(算法导论思路实现)
#include #include #include #include using namespace std; const int maxn = 10005; int color[maxn]; //0代表白色,1代表灰色,2代表黑色 vector vec[maxn]; //邻接表 int step; //全局变量代表总步数 int stime[maxn]; //每个点遍历的时候的起始时间 i原创 2015-07-14 10:57:58 · 579 阅读 · 0 评论 -
DFS拓扑排序(算法导论思路)
#include #include #include #include #include #include using namespace std; const int maxn = 10005; int color[maxn]; //0代表白色,1代表灰色,2代表黑色 vector vec[maxn]; //邻接表 int step; //全局变量代表总步数 int stime[maxn];原创 2015-07-14 12:31:06 · 869 阅读 · 0 评论
分享