![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
水能zai舟
每一次提交务必慎重,切勿基于样例解题。
展开
-
二叉树-已知前序中序求后序
HDU - 1710 A binary tree is a finite set of vertices that is either empty or consists of a root r and two disjoint binary trees called the left and right subtrees. There are three most important原创 2018-01-25 20:49:45 · 850 阅读 · 0 评论 -
二叉树的三序遍历-非递归实现
数据测试题源:Aizu - ALDS1_7_C Tree Walk Binary trees are defined recursively. A binary treeTis a structure defined on a finite set of nodes that either contains no nodes, or is composed of three disjo...原创 2019-09-22 22:49:20 · 226 阅读 · 0 评论 -
搜索树
在此以链式存储的方式实现,为平衡树做铺垫,实现搜索树的:插入(构建)、删除、查找、遍历操作,在此以纯C语言编写(以后有上机考试为纯C,在此适应),使用黑盒测试进行了少量数据验证,欢迎指正。 Code(C) #include <stdio.h> #include <stdlib.h> #include <math.h> #define null NULL #...原创 2019-07-30 19:12:21 · 172 阅读 · 0 评论 -
十字链表存储稀疏矩阵
原理借鉴率辉老师的2020天勤数据结构高分笔记P119-P121部分,代码部分未经大量数据验证可能存在bug,欢迎大家指正。 #include <bits/stdc++.h> using namespace std; /* * 普通节点 */ typedef struct Node { int r, c, v; Node *right, *down; } Node; /* ...原创 2019-07-24 11:54:47 · 498 阅读 · 0 评论 -
稀疏矩阵的乘法
博主备战2020考研,主要实现一些基础数据结构的代码,在此不会做过于详细讲解,仅仅放上代码。 #include <bits/stdc++.h> #define MAX 55 using namespace std; int A[MAX][3], B[MAX][3], C[MAX][3]; int numa, numb, numc, m, n, k; pair<int, int...原创 2019-07-23 22:46:41 · 198 阅读 · 0 评论 -
Kruskal最小生成树模板
感谢博主:https://www.cnblogs.com/aiguona/p/7223625.html?utm_source=itdadao&utm_medium=referral写的挺好的,建议大家看看。 #include <iostream> #include <cstdio> #include <cstring> #include <al...原创 2019-03-13 20:57:10 · 155 阅读 · 0 评论 -
KD树
一维KD树(貌似用不上,但是理解一维有助于理解二维) Code #include <bits/stdc++.h> #define MAX 500005 #define NIL -1 using namespace std; #define for(x, y) for(int i=x; i<y; i++) struct Node1D { int loc, l, r; }; N...原创 2019-01-21 16:19:47 · 759 阅读 · 0 评论 -
并查集
动图解释: Code: #pragma GCC optimize(2) #include <bits/stdc++.h> #define MAX 10005 using namespace std; int p[MAX]; void init(int n) { for (int i = 1; i <= n; i++) p[i] = i; } int fin...原创 2019-01-21 10:05:32 · 104 阅读 · 0 评论 -
SPFA+前向星统计最短路条数
题目:洛谷P1608 路径统计,地址:https://www.luogu.org/problemnew/show/P1608 //#pragma gcc optimize(3) #include <bits/stdc++.h> #define MAX 4000005 #define _MAX 2005 #define INF (1<<30) using namespac...原创 2019-01-20 14:44:13 · 247 阅读 · 0 评论 -
单源最短路SPFA
#include <bits/stdc++.h> #define INF (1<<30) #define MAX 200010 using namespace std; struct edge { int to, next, w; }; edge es[MAX]; int v, e, cnt; int head[MAX], d[MAX], in[MAX]; bool ...原创 2019-01-19 22:22:40 · 129 阅读 · 0 评论 -
链式前向星
以起始点为划分依据,以边为基础单位。 Template #include <bits/stdc++.h> #define MAX 10005 using namespace std; struct edge { int to, next, w; }; edge es[MAX]; int cnt, head[MAX]; void add(int u, int v, int ...原创 2019-01-19 21:22:12 · 144 阅读 · 0 评论 -
堆的实现
#include <bits/stdc++.h> #define MAX_N 1005 using namespace std; class Heap { private: int heap[MAX_N]; int sz; public: Heap() { sz = 0; memset(heap, 0, sizeof(heap)); ...原创 2018-12-08 21:12:02 · 103 阅读 · 0 评论 -
线段树模板
HDU-1166 单点更新 #include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <vector> #include <cmath> #include <set> using namespa原创 2018-04-02 21:53:06 · 96 阅读 · 0 评论 -
双向链表模拟栈的操作
手写双向链表模拟栈的:入栈、出栈、倒置操作。#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <vector> #include <cmath> #include <stack> #inclu原创 2018-04-09 20:03:48 · 510 阅读 · 0 评论 -
数据结构初学者顺序表的操作(精简版)
#include<iostream>#define MAXSIZE 50using namespace std;typedef int Elemtype;struct celltype{ Elemtype data[MAXSIZE]; int length;};void Creat_List(celltype &L){ L.length=0; //初始化,必...原创 2017-03-05 17:13:36 · 550 阅读 · 0 评论 -
最短路-dijkstra与floyd的邻接矩阵模板示例
/*测试数据 Input: 6 9 ABCDEF 0 2 4 0 3 28 1 0 2 1 4 10 2 1 15 2 5 8 4 3 4 5 4 18 5 3 13 Output: MGraph MAT(Dijkstra): 0 * 4 28 * * 2 0 * * 10 * * 15 0 * * 8 * * * 0 *原创 2018-01-26 10:33:06 · 325 阅读 · 0 评论 -
二叉树中序线索化
#include <bits/stdc++.h> using namespace std; typedef struct TBTNode { char data; int ltag, rtag; struct TBTNode *lchild, *rchild; } TBTNode; void visit(TBTNode *p) { cout <...原创 2019-09-23 22:45:12 · 195 阅读 · 0 评论