1、二叉树的应用-哈夫曼树(电文的编码和译码)

1、二叉树的应用-哈夫曼树(电文的编码和译码)
哈夫曼编码/译码器
问题描述:设计一个哈夫曼编码/译码系统,对字符串进行编码/译码
基本要求:
(1)从键盘输入字符串,以回车结束;
(2)根据字符串中字符出现的概率进行哈夫曼编码;)
(3)并输出编码结果和编码表;
(4)根据编码结果和编码表还原字符串;
(5)输出编码过程中构造的哈夫曼树。
cwb94191034 1年前 已收到1个回答 举报

心之疙瘩 花朵

共回答了22个问题采纳率:95.5% 举报

#include
#include
int n;
int m=2*n-1;

struct tree
{
float weight;
int parent;
int lch,rch;
};
struct codetype
{
int bits[100];
int start;
char ch;
};
tree hftree[100];
codetype code[99];
void creathuffmantree(int n,int m)
{

int i,j ,p1,p2;
float s1,s2;
for(i=1;i

1年前

8
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 0.170 s. - webmaster@yulucn.com