用C++实现哈夫曼树的代码.docxVIP

  • 5
  • 0
  • 约4.35千字
  • 约 7页
  • 2017-07-12 发布于河南
  • 举报
用C实现哈夫曼树的代码

韩山师范学院数据结构中的哈夫曼树的实现班级:2015级软工班作者:黄俊聪#include iostream#include fstream#include cstring#include cstdlib using namespace std;typedefstruct{char data;int weight;intparent,lchild,rchild;}HTNode,*HuffmanTree;typedef char ** HuffmanCode;void Select(HuffmanTree HT,intn,int m) {HuffmanTree p=HT;inttmp;for(int j=n+1;j=m;j++) {int tag1,tag2,s1,s2; tag1=tag2=256;for(int x=1;x=j-1;x++) { if(p[x].parent==0p[x].weighttag1){ tag1=p[x].weight; s1=x;} }for(int y=1;y=j-1;y++) { if(p[y].parent==0y!=s1p[y].weighttag2) { tag2=p[y].weight;s2=y;} }if(s1s2) //将选出的两个节点中的序号较小的始终赋

文档评论(0)

1亿VIP精品文档

相关文档