随笔分类 - 数据结构
1
摘要:慢慢把一些要老忘记但是很有用的一些东西放这里 1、lower_bound是找第一个大于等于的数 2、upper_bound是找第一个大于的数 3、stringstream ssin(str) 为读取str中的单字,比如hello world ,就会读取hello和world while (ssin
阅读全文
摘要:* 左左就右旋,右右就左旋 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e9; const int maxm = 1e5 + 5; const int inf = 21474
阅读全文
摘要:前中输出后 #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)
阅读全文
摘要:并查集就是给你一个图,里面有很多点,并就是把点合并一个集合,把a点搞为b点父亲;查就是查点在哪个集合,查a点的父亲祖先是谁。 初始化点的父亲是自己 int Find(int x){ if(father[x] != x)//如果父亲不是自己,那就递归找父亲 father[x] = Find(fathe
阅读全文
摘要:bfs像二叉树的层序遍历 像这个图走bfs就{1, 2, 3, 4, 5, 6, 7, 8}这样走; dfs就{1, 2, 5, 6, 3, 7, 8, 4}。 bfs与queue相结合,走到哪就把哪加进queue,出时把最先进的那个点弹出,同时把弹出这个点有关连的点加入queue。 例:Luogu
阅读全文
摘要: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;/
阅读全文
摘要:预备知识:懒惰标志,就是在二叉树里,a有b c两个子儿子,现在要给b c各加1,先不直接加到b c上,把它俩要加的值先加到a上,待要实际用时a再把值传给他们。 线段树是算法竞赛中常用的用来维护 区间信息 的数据结构。 线段树可以在 O(log n) 的时间复杂度内实现单点修改、区间修改、区间查询(区
阅读全文
摘要:typedef struct HeapStruct *MaxHeap; struct HeapStruct{ int *Elements;/* 存储堆元素的数组 */ int Size;/* 堆的当前元素个数 */ int Capacity;/* 堆的最大容量 */ }; MaxHeap Creat
阅读全文
摘要:#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>>
阅读全文
摘要:#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
阅读全文
摘要:#include<bits/stdc++.h> #define MaxVertexNum 100 /* 最大顶点数设为100 */ typedef int Vertex; /* 用顶点下标表示顶点,为整型 */ typedef int WeightType; /* 边的权值设为整型 */ typed
阅读全文
摘要:#include<bits/stdc++.h> #define MaxVertexNum 100 //最大顶点 #define INFINITY 65535 // ∞设为双字节无符号整数的最大值65535 using namespace std; typedef int Vertex; //用顶点下
阅读全文
摘要:#include<bits/stdc++.h> #define MaxSize 100 using namespace std; //哈夫曼树结点结构 typedef struct { int weight;//结点权重 int parent, left, right;//父结点、左孩子、右孩子在数
阅读全文
摘要:#include<bits/stdc++.h> #define MaxSize 100 using namespace std; typedef struct AVLNode *Position; typedef Position AVLTree; struct AVLNode{ int data;
阅读全文
摘要:#include<bits/stdc++.h> #define MaxSize 100 using namespace std; typedef struct TreeNode {//定义二叉树结构 char Data; struct Node *lchild,*rchild; }*BiTree,B
阅读全文
摘要:typedef struct LNode *List; struct LNode{ int Data[MAXSIZE]; int Last;//最后一个,表长为last+1 }; struct LNode L; List PtrL; List MakeEmpty(){ List PtrL; PtrL
阅读全文
摘要: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(
阅读全文
摘要:#include<bits/stdc++.h> #define MaxSize 100 using namespace std; typedef struct Node {//定义二叉树结构 char data; struct Node *lchild,*rchild; }*BiTree,BiTNo
阅读全文
摘要:#include <iostream> #include <cstdio> #include<bits/stdc++.h> using namespace std; //栈 typedef struct{ int *base; int *top; int stacksize; }sqstack; v
阅读全文
摘要:https://blog.csdn.net/Endeavor_G/article/details/80552680 https://blog.csdn.net/qq_39993896/article/category/7319745 这个详细 顺序表:https://blog.csdn.net/la
阅读全文
1

浙公网安备 33010602011771号