树和二叉树chapter 7(4) 哈夫曼树的应用—哈夫曼编码 ThreadBiTree.pptVIP

  • 1
  • 0
  • 约1.17万字
  • 约 44页
  • 2025-08-07 发布于安徽
  • 举报

树和二叉树chapter 7(4) 哈夫曼树的应用—哈夫曼编码 ThreadBiTree.ppt

HaffmanTreeTest.cpp实现测试哈夫曼树以及哈夫曼编码#includeiostream.h#includestdlib.hconstintMaxValue=10000; //初始设定的权值最大值constintMaxBit=4; //初始设定的最大编码位数constintMaxN=10; //初始设定的最大结点个数#includeHaffmanTree.hvoidmain(void){ inti,j,n=4; intweight[]={1,3,5,7}; HaffNode*myHaffTree=newHaffNode[2*n+1]; Code*myHaffCode=newCode[n]; if(nMaxN){coutn越界,修改MaxN!endl;exit(0);} Haffman(weight,n,myHaffTree); HaffmanCode(myHaffTree,n,myHaffCode); //输出每个叶结点的哈夫曼编码 for(i=0;in;i++) { coutWeight=myHaffCode[i].weightCode=; for(j=myHaffCode[i].start+1;

文档评论(0)

1亿VIP精品文档

相关文档