![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
文章平均质量分 57
qingfengpapa
为什么我的眼中常含泪水,因为我还有一个算法不会。。。
展开
-
模式匹配(子串问题)
B-F算法 就是暴力搜索,易于理解,效率不高 KMP算法 关键就是预处理NEXT数组,利用之前的失败信息减少主串匹配次数。不需要回溯是关键啦~ #include #include using namespace std; template class Node { private: public: typedef struct pNode原创 2015-05-23 15:41:06 · 407 阅读 · 0 评论 -
FLOYD
求出图中两顶点间的最短路径,让我们想到的是DIJIKSTRA算法,即单源最短路径的算法。那如果求所有顶点两两之间的最短路径的值,是否只要调用N次DIJIKSTRA了?当然可以,其时间复杂度为O(N3),然而这样做,你会发现代码还是比较复杂的。 这时,用佛罗伊德算法,是比较好的,当然他的时间复杂度也为O(N3).空间复杂度为O(N2)。 不过,有意思的是,佛罗伊德算法其实是基于动态规划的!这一点自行百原创 2015-06-07 08:42:50 · 378 阅读 · 0 评论 -
图的邻接多重表存储
Triple.h//用二维数组初始化每条边的值 template<class T> class Triple { public: int data[100][3]; Triple() { } /*Triple(int arr[][],int n) { for(int i =原创 2015-06-07 08:29:29 · 657 阅读 · 0 评论 -
最小生成树prime
prime算法 每次加入已(加入树集合)结点连着(未加入树)的最短边直至所有结点加入最小生成树 源代码: #include #include #include #define ssize_t 100 #define max_int 123456789 typedef struct Node { int map[ssize_t][ssize_t]; int n_num;原创 2015-05-24 14:21:16 · 429 阅读 · 0 评论 -
0-1背包
0-1背包问题 动态规划 -----先传程序,以后写理解 #include #include #include int dp(int n,int weight,int *w,int *value) { int i; int j; int max_value[100][100]; memset(max_value,0,sizeof(max_value)); f原创 2015-05-24 17:48:34 · 270 阅读 · 0 评论 -
Dijikstra(单源最短路径)
Dijikstra(单源最短路径)求无向图中两点间的最短路径 时间复杂度O(N2)代码#include<stdio.h> #include<stdlib.h> #define max 100 #define maxint 32767typedef struct Node { int map[max][max]; //邻接表 int n; //顶原创 2015-05-24 19:30:49 · 909 阅读 · 0 评论 -
python带锁的队列
__author__ = 'Mrsong' #encoding='utf-8' import queue import threading class ConcurrentQueue: def __init__(self, capacity = -1): self.__capacity = capacity #初始化队列原创 2016-12-01 12:53:00 · 2809 阅读 · 0 评论