![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
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 · 441 阅读 · 0 评论 -
【二叉树】已知后序与中序求先序
【二叉树遍历】已知后序与中序输出先序思想后序最后一个结点位置为root中序第一个结点位置为start 最后一个结点位置为end先序顺序为根左右后序最后结点一定为整棵树的根结点在中序中找到该根结点位置i 位置i左面为左子树 位置i右面为右子树左子树的根结点在后序的位置为最后位置根结点root减去右子树的所有结点end-i+1即root+i-end-1左子树第一个结点位置为start ...原创 2019-11-03 21:42:40 · 1236 阅读 · 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 · 147 阅读 · 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 · 80 阅读 · 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 · 119 阅读 · 0 评论 -
【线性表】线性表的链式存储结构
【线性表】线性表的链式存储结构代码#include <iostream>#include <cstdio>using namespace std;#define OK 1#define ERROR 0#define LIST_INIT_SIZE 100#define LISTINCREMENT 10typedef int status;typedef i...原创 2019-10-30 15:40:58 · 95 阅读 · 0 评论 -
【线性表】线性表的顺序存储结构
【线性表】线性表的顺序存储结构代码#include <iostream>#include <cstdio>using namespace std;#define OK 1#define ERROR 0#define LIST_INIT_SIZE 100#define LISTINCREMENT 10typedef int status;typedef i...原创 2019-10-30 15:38:09 · 81 阅读 · 0 评论 -
【循环队列】队列的顺序存储结构
【循环队列】队列的顺序存储结构代码#include <iostream>#include <cstdio>using namespace std;#define OK 1#define ERROR 0typedef int status;typedef int QElemType;#define MAXQSIZE 100typedef struct{ ...原创 2019-10-30 15:37:12 · 78 阅读 · 0 评论 -
【队列】队列的链式存储结构
【队列】队列的链式存储结构代码#include <iostream>#include <cstdio>using namespace std;#define OK 1#define ERROR 0typedef int status;typedef int QElemType;typedef struct QNode{ QElemType data...原创 2019-10-30 15:30:58 · 100 阅读 · 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 · 200 阅读 · 0 评论 -
【栈】栈的顺序存储表示
【栈】栈的顺序存储表示代码#include <iostream>#include <cstdio>using namespace std;#define OK 1#define ERROR 0#define STACK_INIT_SIZE 100#define STACKINCREMENT 10typedef int status;typedef int...原创 2019-10-30 15:26:02 · 83 阅读 · 0 评论