
二叉树
文章平均质量分 71
WQJ0714
曾经失败过,不代表永远失败。
展开
-
树结构练习——排序二叉树的中序遍历
题目描述 在树结构中,有一种特殊的二叉树叫做排序二叉树,直观的理解就是——(1).每个节点中包含有一个关键值 (2).任意一个节点的左子树(如果存在的话)的关键值小于该节点的关键值 (3).任意一个节点的右子树(如果存在的话)的关键值大于该节点的关键值。现给定一组数据,请你对这组数据按给定顺序建立一棵排序二叉树,并输出其中序遍历的结果。 输入 输入包含多组数据,每组原创 2015-02-07 14:27:14 · 496 阅读 · 0 评论 -
树结构练习——判断给定森林中有多少棵树
#include #include using namespace std; int main() { int n,m,j,i,x,y; int b[1000]; while(cin>>n>>m) { for(i=0;i<m;i++) cin>>x>>y; cout<<n-m<<endl; }原创 2015-11-27 21:26:49 · 686 阅读 · 0 评论 -
数据结构实验之二叉树三:统计叶子数
#include #include #include using namespace std; int cnt; char s[101]; struct node { char data; struct node *rchild; struct node *lchild; }; struct node *buildtree() { struct node原创 2015-11-27 21:28:48 · 425 阅读 · 0 评论 -
数据结构实验之二叉树四:还原二叉树
#include #include using namespace std; struct node { char data; struct node *lchild,*rchild; }; struct node *creat(int n,char a[],char b[]) { char *p; struct node *root; if(n==原创 2015-11-27 21:31:10 · 1172 阅读 · 0 评论 -
二叉树模版
#include #include #include using namespace std; char cache[101]; struct Node { char data; struct Node * lchild,* rchild; }; struct Node * root; int cnt; //构造二叉树 struct Node * Build_tree()原创 2015-11-27 21:23:54 · 373 阅读 · 0 评论 -
二叉树的建立及前中后序遍历
#include #include #include using namespace std; typedef struct BiNode { char data; struct BiNode *lch; struct BiNode *rch; }BiNode,*BiTree; void creat(BiTree &T) { T=(BiNode*)mallo原创 2015-11-27 21:25:37 · 505 阅读 · 0 评论 -
数据结构实验之二叉树七:叶子问题
#include #include #include #include using namespace std; char s[101]; struct Node { char data; struct Node * lchild,* rchild; }; struct Node * root; int cnt; //构造二叉树 struct Node * Build_原创 2015-11-27 21:28:05 · 1045 阅读 · 0 评论 -
数据结构实验之二叉树五:层序遍历
#include #include #include #include using namespace std; char s[101]; struct Node { char data; struct Node * lchild,* rchild; }; struct Node * root; int cnt; //构造二叉树 struct Node * Build_原创 2015-11-27 21:31:53 · 356 阅读 · 0 评论