随笔分类 -  数据结构

1
摘要:慢慢把一些要老忘记但是很有用的一些东西放这里 1、lower_bound是找第一个大于等于的数 2、upper_bound是找第一个大于的数 3、stringstream ssin(str) 为读取str中的单字,比如hello world ,就会读取hello和world while (ssin 阅读全文
posted @ 2022-02-26 22:14 acwarming 阅读(41) 评论(0) 推荐(0)
摘要:* 左左就右旋,右右就左旋 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e9; const int maxm = 1e5 + 5; const int inf = 21474 阅读全文
posted @ 2021-02-17 20:59 acwarming 阅读(238) 评论(0) 推荐(0)
摘要:前中输出后 #include<iostream> using namespace std; int pre[] = {1, 2, 3, 4, 5, 6}; int mid[] = {3, 2, 4, 1, 6, 5}; void post(int root, int start, int end) 阅读全文
posted @ 2021-01-03 23:47 acwarming 阅读(109) 评论(0) 推荐(0)
摘要:并查集就是给你一个图,里面有很多点,并就是把点合并一个集合,把a点搞为b点父亲;查就是查点在哪个集合,查a点的父亲祖先是谁。 初始化点的父亲是自己 int Find(int x){ if(father[x] != x)//如果父亲不是自己,那就递归找父亲 father[x] = Find(fathe 阅读全文
posted @ 2020-11-19 12:49 acwarming 阅读(127) 评论(0) 推荐(0)
摘要:bfs像二叉树的层序遍历 像这个图走bfs就{1, 2, 3, 4, 5, 6, 7, 8}这样走; dfs就{1, 2, 5, 6, 3, 7, 8, 4}。 bfs与queue相结合,走到哪就把哪加进queue,出时把最先进的那个点弹出,同时把弹出这个点有关连的点加入queue。 例:Luogu 阅读全文
posted @ 2020-11-19 12:43 acwarming 阅读(131) 评论(0) 推荐(0)
摘要:Bellman Ford不常用下面有它的优化SPFA for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { d[v[i]] = min(d[v[i]], d[u[i]] + w[i]); } } Dijkstra d[s] = 0;/ 阅读全文
posted @ 2020-11-19 12:42 acwarming 阅读(140) 评论(0) 推荐(0)
摘要:预备知识:懒惰标志,就是在二叉树里,a有b c两个子儿子,现在要给b c各加1,先不直接加到b c上,把它俩要加的值先加到a上,待要实际用时a再把值传给他们。 线段树是算法竞赛中常用的用来维护 区间信息 的数据结构。 线段树可以在 O(log n) 的时间复杂度内实现单点修改、区间修改、区间查询(区 阅读全文
posted @ 2020-11-19 12:35 acwarming 阅读(98) 评论(0) 推荐(0)
摘要:typedef struct HeapStruct *MaxHeap; struct HeapStruct{ int *Elements;/* 存储堆元素的数组 */ int Size;/* 堆的当前元素个数 */ int Capacity;/* 堆的最大容量 */ }; MaxHeap Creat 阅读全文
posted @ 2020-02-18 17:26 acwarming 阅读(187) 评论(0) 推荐(1)
摘要:#include<bits/stdc++.h> using namespace std; int a[11][11]; bool visited[11]; void store_graph() { for(int i=1;i<=10;i++) for(int j=1;j<=10;j++) cin>> 阅读全文
posted @ 2020-01-31 16:28 acwarming 阅读(173) 评论(0) 推荐(0)
摘要:#include<bits/stdc++.h> using namespace std; int a[11][11]; bool visited[11]; void store_graph(){//邻接矩阵存储图 int i,j; for(i = 1; i <= 10; i++) for(j = 1 阅读全文
posted @ 2020-01-31 16:26 acwarming 阅读(388) 评论(0) 推荐(0)
摘要:#include<bits/stdc++.h> #define MaxVertexNum 100 /* 最大顶点数设为100 */ typedef int Vertex; /* 用顶点下标表示顶点,为整型 */ typedef int WeightType; /* 边的权值设为整型 */ typed 阅读全文
posted @ 2019-12-28 16:34 acwarming 阅读(207) 评论(0) 推荐(0)
摘要:#include<bits/stdc++.h> #define MaxVertexNum 100 //最大顶点 #define INFINITY 65535 // ∞设为双字节无符号整数的最大值65535 using namespace std; typedef int Vertex; //用顶点下 阅读全文
posted @ 2019-12-28 16:15 acwarming 阅读(464) 评论(0) 推荐(0)
摘要:#include<bits/stdc++.h> #define MaxSize 100 using namespace std; //哈夫曼树结点结构 typedef struct { int weight;//结点权重 int parent, left, right;//父结点、左孩子、右孩子在数 阅读全文
posted @ 2019-12-27 16:10 acwarming 阅读(248) 评论(0) 推荐(0)
摘要:#include<bits/stdc++.h> #define MaxSize 100 using namespace std; typedef struct AVLNode *Position; typedef Position AVLTree; struct AVLNode{ int data; 阅读全文
posted @ 2019-12-25 20:46 acwarming 阅读(163) 评论(0) 推荐(0)
摘要:#include<bits/stdc++.h> #define MaxSize 100 using namespace std; typedef struct TreeNode {//定义二叉树结构 char Data; struct Node *lchild,*rchild; }*BiTree,B 阅读全文
posted @ 2019-12-25 16:47 acwarming 阅读(440) 评论(0) 推荐(0)
摘要:typedef struct LNode *List; struct LNode{ int Data[MAXSIZE]; int Last;//最后一个,表长为last+1 }; struct LNode L; List PtrL; List MakeEmpty(){ List PtrL; PtrL 阅读全文
posted @ 2019-12-04 15:33 acwarming 阅读(136) 评论(0) 推荐(0)
摘要:kmp,next带优化 #include<iostream> #include<bits/stdc++.h> using namespace std; void getnext(char p[],int next[]){ next[0]=-1; int i=0,j=-1; int n=strlen( 阅读全文
posted @ 2019-11-14 11:34 acwarming 阅读(207) 评论(0) 推荐(0)
摘要:#include<bits/stdc++.h> #define MaxSize 100 using namespace std; typedef struct Node {//定义二叉树结构 char data; struct Node *lchild,*rchild; }*BiTree,BiTNo 阅读全文
posted @ 2019-11-06 19:25 acwarming 阅读(264) 评论(0) 推荐(0)
摘要:#include <iostream> #include <cstdio> #include<bits/stdc++.h> using namespace std; //栈 typedef struct{ int *base; int *top; int stacksize; }sqstack; v 阅读全文
posted @ 2019-11-05 17:02 acwarming 阅读(165) 评论(0) 推荐(0)
摘要:https://blog.csdn.net/Endeavor_G/article/details/80552680 https://blog.csdn.net/qq_39993896/article/category/7319745 这个详细 顺序表:https://blog.csdn.net/la 阅读全文
posted @ 2019-09-17 21:38 acwarming 阅读(153) 评论(0) 推荐(0)

1