![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
树
ZMST
这个作者很懒,什么都没留下…
展开
-
PAT——A1079 Total Sales of Supply Chain(树BFS)
题目链接:#include<cstdio>#include<cstring>#include<vector>#include<algorithm>#include<math.h>#include<cmath>using namespace std;#define maxn 100010struct nod...原创 2018-08-30 20:27:05 · 158 阅读 · 0 评论 -
PAT——A1090 Highest Price in Supply Chain(树的遍历)
题目链接:#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>using namespace std;#define maxn 100010vector&l...原创 2018-08-30 10:30:37 · 132 阅读 · 0 评论 -
天梯赛——小字辈(树的遍历 BFS vector)
题目链接:#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<map>#include<set>u原创 2018-08-30 13:19:37 · 427 阅读 · 0 评论 -
zcmu 4931: 二叉树遍历
题目链接:#include<cstdio>#include<iostream>#include<map>#include<algorithm>#include<vector>#include<cmath>#include<cstring>using namespace std;char pre原创 2018-09-08 21:19:01 · 149 阅读 · 0 评论 -
zcmu——4399二叉排序树(构建二叉树)
题目链接:#include<cstdio>#include<iostream>#include<map>#include<algorithm>#include<vector>#include<cmath>#include<cstring>using namespace std;struct n原创 2018-09-09 14:58:05 · 204 阅读 · 0 评论 -
树节点创建,插入,树的构造,前序遍历
#include<cstdio>#include<iostream>#include<cstring>#include<vector>#include<cmath>#include<algorithm>using namespace std;int a[1001];struct node{ int d...原创 2018-09-09 15:18:46 · 694 阅读 · 0 评论 -
zcmu——4934: 二叉搜索树
题目链接【分析】一开始不知道如何做因为觉得一个序列不可能确定一颗唯一的树其实二叉搜索树(或者二叉查找数、二叉排序树)是可以的它的左孩子永远小于根右孩子永远大于根所以还以那一套模板建树、建结点、插入然后判断是否是同一个二叉搜索树可以先用前序遍历然后看看遍历出来的顺序是否相等就可以了#include<cstdio>#include<...原创 2018-09-12 21:13:58 · 234 阅读 · 0 评论 -
PAT——A1153 LCA in a Binary Tree(2018秋PAT D题30")
题目链接:考试的时候只记得写遍历成二叉树但是题意竟然没看对卡了很久就是求最小祖宗再加一个DFS就好了呀#include<cstdio>#include<iostream>#include<cstring>#include<vector>#include<cmath>#include<algorit...原创 2018-09-10 09:33:05 · 236 阅读 · 0 评论 -
PAT——A1066 Root of AVL Tree(AVL)
题目链接:#include<cstdio>#include<iostream>#include<algorithm>#include<vector>using namespace std;struct node{ int v,height; node *lchild,*rchild;}*root;node* new...原创 2018-09-01 14:59:18 · 95 阅读 · 0 评论 -
PAT——A1102 Invert a Binary Tree(invert反转 + 遍历)
题目链接:#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<stack>#include<queue>using namespace std;#define原创 2018-08-29 10:45:38 · 147 阅读 · 0 评论 -
PAT——A1094 The Largest Generation(树的遍历,DFS)
题目链接:#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<map>#include<set>u原创 2018-08-31 09:59:51 · 126 阅读 · 0 评论 -
PAT——A1106 Lowest Price in Supply Chain(树 DFS)
题目链接:#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<map>#include<set>u原创 2018-08-31 10:50:09 · 124 阅读 · 0 评论 -
PAT——A1004 Counting Leaves(树 DFS)
题目链接:#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<map>#include<set>u原创 2018-08-31 13:03:18 · 133 阅读 · 0 评论 -
PAT——A1020 Tree Traversals(树)
题目链接:#include<cstdio>#include<algorithm>#include<cmath>#include<cstring>#include<queue>using namespace std;#define maxn 50struct node{ int data; node* l...原创 2018-08-28 19:59:01 · 131 阅读 · 0 评论 -
PAT——A1053 Path of Equal Weight
题目链接:#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<vector>#include<map>#include<queue>原创 2018-08-31 19:27:05 · 151 阅读 · 0 评论 -
PAT——A1086 Tree Traversals Again(二叉树遍历)
题目链接:#include<cstdio>#include<iostream>#include<cstring>#include<algorithm>#include<cmath>#include<stack>#include<queue>using namespace std;#define原创 2018-08-29 10:05:40 · 141 阅读 · 0 评论 -
PAT——A1143Lowest Common Ancestor(二叉树重建)
题目链接:一开始以为要重建二叉树可是只有一个前序重建不了其实有一个前序只要找到根即可根在左孩子和右孩子前面所以只要找到肯定是根【注意】找到一个findnode在不在数中的方法就是只要建立一个set只要count不到就找不到很简单的其实把前序从小到大排列就是中序了可以试试#include<vector>#includ...原创 2018-09-10 21:16:17 · 440 阅读 · 0 评论