树及二叉树
西杭
温水煮了将军梦
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
利用哈夫曼编码压缩文本
文章目录使用哈夫曼编码进行压缩文本文本内容读取文件内容至内存中遍历文本内容,获取每个字符对应出现概率值建立哈夫曼树获取哈夫曼编码将转换后的编码写入新文件检测压缩率利用编码文件进行还原文本完整code使用哈夫曼编码进行压缩文本文本内容Even though neural network-based models have achieveda lot, there are several im...原创 2020-04-12 16:27:21 · 3851 阅读 · 8 评论 -
数据结构实验之查找三:树的种类统计
输出结果无错, 算法无错, 但就是WA。改不出来,如若指正,不胜感激。题目链接#include#include#include#include#includeusing namespace std;typedef struct node{ string data; node *l, *r; int num;} Tree;Tree *cre原创 2016-08-11 16:43:07 · 485 阅读 · 0 评论 -
数据结构实验之查找一:二叉排序树
数据结构实验之查找一:二叉排序树Time Limit: 400MS Memory Limit: 65536KBSubmit StatisticProblem Description对应给定的一个序列可以唯一确定一棵二叉排序树。然而,一棵给定的二叉排序树却可以由多种不同的序列得到。例如分别按照序列{3,1,4}和{3,4,1}插入初始为空的二叉排序树,都得到一样的结果原创 2016-11-29 19:26:02 · 765 阅读 · 0 评论 -
数据结构实验之查找二:平衡二叉树
数据结构实验之查找二:平衡二叉树Time Limit: 400MS Memory Limit: 65536KBSubmit StatisticProblem Description根据给定的输入序列建立一棵平衡二叉树,求出建立的平衡二叉树的树根。Input输入一组测试数据。数据的第1行给出一个正整数N(n Output输出平衡原创 2016-12-01 13:43:17 · 674 阅读 · 0 评论 -
树的同构
数据结构实验之二叉树一:树的同构Time Limit: 1000MS Memory Limit: 65536KBSubmit StatisticProblem Description给定两棵树T1和T2。如果T1可以通过若干次左右孩子互换就变成T2,则我们称两棵树是“同构”的。例如图1给出的两棵树就是同构的,因为我们把其中一棵树的结点A、B、G的左右孩子互换后,就得原创 2016-11-01 21:57:16 · 659 阅读 · 0 评论 -
数据结构实验之二叉树六:哈夫曼编码
再上一个题的基础上略作修改题目链接C++如何用cout输出小数, 如下:头文件 : #include cout#include#include#include#include#include#includeusing namespace std;double num[100000];char ss[100000];int samechar(st原创 2016-08-12 14:58:19 · 707 阅读 · 0 评论 -
树-堆结构练习——合并果子之哈夫曼树
利用优先队列完成。题目链接#include#include#includeusing namespace std;int main(){ ios::sync_with_stdio(false); int n, last, sum, t; priority_queue, greater >p;///定义优先队列p; whi原创 2016-08-12 11:03:33 · 701 阅读 · 0 评论 -
树结构练习——判断给定森林中有多少棵树
水题题目链接#include#include#includeusing namespace std;const int maxn=100000;int x[maxn];int main(){ ios::sync_with_stdio(false); int n, m; while(cin>>n>>m) { memse原创 2016-08-12 09:25:38 · 1015 阅读 · 0 评论 -
二叉排序树
此题高能预警题目链接#include#include#include#includeusing namespace std;typedef struct node{ char data; node *l; node *r;}Tree;Tree *creat(char key, Tree *root){ if(root==NULL)原创 2016-08-10 15:51:14 · 534 阅读 · 0 评论 -
树结构练习——排序二叉树的中序遍历
中序输出其实就是从小到大输出,sort就可以了题目链接#include#include#include#includeusing namespace std;typedef struct node{ int data; struct node *l; struct node *r;}Tree;Tree *creat(int key, Tre原创 2016-08-09 19:20:24 · 611 阅读 · 0 评论 -
求二叉树的深度
题目链接#include#include#include#includeusing namespace std;typedef struct node{ char data; struct node *l; struct node *r;}Tree;Tree *creat(int n, char *a, char *b){ Tree *原创 2016-08-09 15:13:37 · 449 阅读 · 0 评论 -
数据结构实验之求二叉树后序遍历和层次遍历
题目链接#include#include#include#includeusing namespace std;typedef struct node{ char data; struct node *l; struct node *r;}Tree;Tree *creat(int n, char *a, char *b){ Tree *原创 2016-08-09 15:05:45 · 414 阅读 · 0 评论 -
数据结构实验之二叉树四:还原二叉树
题目链接#include#include#includeusing namespace std;typedef struct node{ char data; struct node *l; struct node *r;}Tree;Tree *creat(int n, char *a, char *b){ Tree *root;原创 2016-08-09 14:49:39 · 479 阅读 · 0 评论 -
数据结构实验之二叉树七:叶子问题
题目链接#include#include#includeusing namespace std;string a;int l1;typedef struct node{ char data; struct node *lchild,*rchild;}Tree;Tree *creat()///先序建立二叉树{ Tree *root; char c; c=a[原创 2016-08-08 15:44:38 · 664 阅读 · 0 评论 -
数据结构实验之二叉树五:层序遍历
借助队列实现题目链接#include#include#includeusing namespace std;string a;int l1;typedef struct node{ char data; struct node *lchild,*rchild;}Tree;struct node *creat()///先序建立二叉树{ Tree *原创 2016-08-08 15:05:18 · 846 阅读 · 0 评论 -
数据结构实验之二叉树二:遍历二叉树
题目链接#include#include#include#include#includeusing namespace std;string a;int l1;typedef struct node{ char data; struct node *lchild,*rchild;}Tree;struct node *creat()///先序建立二叉树{原创 2016-08-08 11:34:36 · 415 阅读 · 0 评论 -
数据结构实验之二叉树的建立与遍历
题目链接#include#include#include#includetypedef struct node{ int data; struct node *l; struct node *r;}Tree;Tree *p;int count = 0;Tree *creat(Tree *p){ char c; if((c =原创 2016-08-08 11:03:43 · 708 阅读 · 0 评论 -
数据结构实验之二叉树三:统计叶子数
题目链接#include#include#includechar a[150];int l1;struct node{ int data; struct node *lchild,*rchild;};struct node *creat()///先序建立二叉树{ struct node *root; char c; c=a[l1++]; if(c==','原创 2016-08-08 11:00:57 · 601 阅读 · 0 评论
分享