给定权值40,30,15,5,4,3,3,构造相应的哈夫曼树及其编码.

伤心小文 1年前 已收到1个回答 举报

凤舞5201314 幼苗

共回答了14个问题采纳率:92.9% 举报

以下是我做个的类似的题的代码:
#include
#include
#include
#include
#include
usingnamespace std;
typedefstruct{ //哈夫曼树的结构体
char ch;
int weight; //权值
int parent,lchild,rchild;
}hnode,*hfmtree;
typedefchar **hfmcode;

void Select(hfmtree &TREE,inta,int *p1,int *p2) //Select函数,选出TREE树到a为止,权值最小且parent为0的2个节点
{
int i,j,x,y;
for(j=1;j

1年前

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