struct TreeNode
{
int Weight;
HuffmanTree Left,Right;
};
HuffmanTree Huffman(MinHeap H)
{
int i;
HuffmanTree T;
BuildMinHeap(H);
for(int i=1;i<H->size;i++)
{
T=malloc(sizeof(struct TreeNode));
T->Left=DeleteMin(H);
T->Right=DeleteMin(H);
T->Weight=T->Left->Weight+T->right->Weight;
Insert(H,T);
}
T=DeleteMin(H);
return T;
}
创建哈曼夫树
最新推荐文章于 2024-04-20 11:37:23 发布