
数据结构
Yo3ngLau
Grazie
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【二叉树】已知前序、中序求后序
【二叉树】已知前序、中序求后序 代码 #include <iostream> #include <cstdio> #include <vector> using namespace std; vector<int> pre, in, post; // 后序 左右根 void post_order(int root, int start, int en...原创 2019-11-21 23:28:28 · 521 阅读 · 0 评论 -
【二叉树】已知后序与中序求先序
【二叉树遍历】已知后序与中序输出先序 思想 后序最后一个结点位置为root 中序第一个结点位置为start 最后一个结点位置为end 先序顺序为根左右 后序最后结点一定为整棵树的根结点 在中序中找到该根结点位置i 位置i左面为左子树 位置i右面为右子树 左子树的根结点在后序的位置为最后位置根结点root减去右子树的所有结点end-i+1即root+i-end-1 左子树第一个结点位置为start ...原创 2019-11-03 21:42:40 · 1386 阅读 · 0 评论 -
【数组】矩阵的压缩存储
【数组】矩阵的压缩存储 代码 #include <iostream> #include <cstdio> #include <cmath> using namespace std; #define mm(a) memset(a, 0, sizeof(a)) const int MAXN = 11; int n, pos; int matrix[MAXN][MAX...原创 2019-10-30 16:22:40 · 202 阅读 · 0 评论 -
【斐波那契】斐波那契数列的三种实现
【斐波那契】斐波那契数列的三种实现 代码 #include <iostream> #include <cstdio> #include <stack> using namespace std; int Fibonacci(int n){ //递归实现 if (!n) return 0; else if (n == 1) return 1; ...原创 2019-10-30 16:22:48 · 121 阅读 · 0 评论 -
【汉诺塔】递归实现汉诺塔
【汉诺塔】递归实现汉诺塔 代码 #include <iostream> #include <cstdio> using namespace std; int cnt = 0; void moving(int disk, char m, char n){ printf("第%d次c移动:把%d号圆盘从%c移动到%c\n", ++cnt, disk, m, n); } ...原创 2019-10-30 16:22:54 · 153 阅读 · 0 评论 -
【线性表】线性表的链式存储结构
【线性表】线性表的链式存储结构 代码 #include <iostream> #include <cstdio> using namespace std; #define OK 1 #define ERROR 0 #define LIST_INIT_SIZE 100 #define LISTINCREMENT 10 typedef int status; typedef i...原创 2019-10-30 15:40:58 · 134 阅读 · 0 评论 -
【线性表】线性表的顺序存储结构
【线性表】线性表的顺序存储结构 代码 #include <iostream> #include <cstdio> using namespace std; #define OK 1 #define ERROR 0 #define LIST_INIT_SIZE 100 #define LISTINCREMENT 10 typedef int status; typedef i...原创 2019-10-30 15:38:09 · 107 阅读 · 0 评论 -
【循环队列】队列的顺序存储结构
【循环队列】队列的顺序存储结构 代码 #include <iostream> #include <cstdio> using namespace std; #define OK 1 #define ERROR 0 typedef int status; typedef int QElemType; #define MAXQSIZE 100 typedef struct{ ...原创 2019-10-30 15:37:12 · 125 阅读 · 0 评论 -
【队列】队列的链式存储结构
【队列】队列的链式存储结构 代码 #include <iostream> #include <cstdio> using namespace std; #define OK 1 #define ERROR 0 typedef int status; typedef int QElemType; typedef struct QNode{ QElemType data...原创 2019-10-30 15:30:58 · 155 阅读 · 0 评论 -
【二叉树】建树以及先中后序递归与非递归遍历
【二叉树】建树以及先中后序遍历 代码 #include <iostream> #include <cstdio> #include <cstdlib> using namespace std; int level = 1; typedef struct node{ char data; struct node *lchild; struc...原创 2019-10-30 10:41:26 · 310 阅读 · 0 评论 -
【栈】栈的顺序存储表示
【栈】栈的顺序存储表示 代码 #include <iostream> #include <cstdio> using namespace std; #define OK 1 #define ERROR 0 #define STACK_INIT_SIZE 100 #define STACKINCREMENT 10 typedef int status; typedef int...原创 2019-10-30 15:26:02 · 138 阅读 · 0 评论