随笔分类 -  数据结构

二叉树的查找
摘要:实际上跟我上一篇博文重了,这篇多加了查找上一篇文章#include#include#includeusing namespace std;typedef struct node{ struct node *leftchild; struct node *rightchild; ch... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(179) 评论(0) 推荐(0)

图论 用广搜搜邻接矩阵
摘要:用广搜搜邻接矩阵只是从某一点开始搜,如果是遍历全图的话就每个顶点挨个搜一遍#include#include#include#include#include#include#define inf 65535using namespace std;typedef struct mygraph{ i... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(100) 评论(0) 推荐(0)

图论 邻接表建图+dfs
摘要:上一篇用的是邻接矩阵建图:点击打开链接所以dfs(&G,0)结果为0 2 3 4 1dfs(&G,1)结果为1 2 3 4dfs(&G,2)结果为2 3 4dfs(&G,3)结果为 3 4 dfs(&G,4)结果为4#include#include#include#includeusing name... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(186) 评论(0) 推荐(0)

图论 迪杰斯特拉dijkstra求最短路径
摘要:这个测试用的是下面这个图:9 160 1 2 3 4 5 6 7 80 1 10 2 51 2 31 4 51 3 72 4 12 5 73 4 23 6 34 6 94 5 34 7 95 7 56 7 26 8 77 8 4运行结果如下:#include#include#include#incl... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(150) 评论(0) 推荐(0)

图论 用prim法求最小生成树
摘要:我用的是邻接矩阵保存的图测试数据二所用的图如下:具体说明都在下面这段代码里(如果不嫌弃可以仔细阅读)#include#include#include#include#define inf 65535#includetypedef struct Graph{ int vertex[100]; ... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(211) 评论(0) 推荐(0)

图论 邻接表广搜
摘要:上一篇是邻接表dfs:点击打开链接所以bfs(&G,0)结果为0 2 1 3 4bfs(&G,1)结果为1 2 3 4bfs(&G,2)结果为2 3 4bfs(&G,3)结果为 3 4 bfs(&G,4)结果为4#include#include#include#include#includeusin... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(210) 评论(0) 推荐(0)

递归建立二叉树
摘要:第一次建立二叉树,终于实现了,之前一直看书,非常枯燥,看得想睡觉。现在有兴趣把刚刚落下的东西补起来了。#include#include#includeusing namespace std;typedef struct node{ struct node *leftchild; stru... 阅读全文

posted @ 2017-09-19 23:09 横济沧海 阅读(105) 评论(0) 推荐(0)

Floyd最短路
摘要:用邻接矩阵实现floyd找最短路算法测试所用图如下:#include#include#include#include#include#include#include#define inf 65535using namespace std;struct Graph//用邻接矩阵来保存图{int arc... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(86) 评论(0) 推荐(0)

邻接表拓扑排序
摘要:测试所用图如下:#include#include#include#include#include#include#include#define OK 1#define ERROR 0using namespace std;typedef struct NODE{int adjvex;int weig... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(512) 评论(0) 推荐(0)

平衡二叉树
摘要:平衡二叉树这里停留了很久,费了很大功夫才弄懂。做个笔记比较好。参考以下两位大佬的博客写的:1: http://www.cnblogs.com/fornever/archive/2011/11/15/2249492.html2: http://blog.csdn.net/followmyinc... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(116) 评论(0) 推荐(0)

数据结构 斐波那契查找
摘要:#include#include#include#include#includeusing namespace std;int f[1005];void init(){ int i,j; f[0]=0; f[1]=1; for(i=2; if[k]-1)k++;//这里执行完... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(143) 评论(0) 推荐(0)

图论 关键路径
摘要:测试所用的AOE图如下:算法参考#include#include#include#include#include#includeusing namespace std;int stack2[100],top2;int etv[100],ltv[100];typedef struct NODE{int... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(218) 评论(0) 推荐(0)

数据结构之顺序线性表
摘要:九层之台起于垒土,千里之行始于足下!数据结构 顺序线性表这个要注意的地方就是线性表中元素编号是从1开始的,但实际储存时却是用相当于数组的方式储存的,元素从0开始储存故可以边画图边理解,下图标上“(reason)”的地方均是这个原因#include#include#include#include#i... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(83) 评论(0) 推荐(0)

数据结构之链式线性表
摘要:带头结点的#include#include#include#include#include#includeusing namespace std;#define OK 1#define ERROR 0typedef int status;typedef struct LNODE{ int da... 阅读全文

posted @ 2017-09-19 23:08 横济沧海 阅读(174) 评论(0) 推荐(0)

导航