赫夫曼树的编码译码.docVIP

  • 0
  • 0
  • 约3.22千字
  • 约 5页
  • 2016-10-13 发布于重庆
  • 举报
赫夫曼树的编码译码

#includestdio.h #includestdlib.h #includestring.h typedef struct{ int weight; int lchild,rchild,parent; }Htnode,*HuffmanTree; //哈弗曼树节点类型,动态分配数组存储哈弗曼树 typedef char * * Huffmancode; //动态分配数组存储哈弗曼编码表 void bianma(Huffmancode ch,int n); //编码 void yima(Htnode *HT, int n); //译码 int createtree(Htnode *HT, Huffmancode HC,int *weight,int n); //构建哈弗曼树 void select(Htnode *HT,int n,int *s1,int *s2); //求节点中两个最小数 /*----------main 函数----------*/ int main (void) { Htnode *HT; int n=4,a; //叶子节点4个 int weight[5]={18,7,5,2,4}; //weight[0]为权值之和 char ch[4]={A,B,C,D},c; char **HC; createtr

文档评论(0)

1亿VIP精品文档

相关文档