#include <stdio.h> #include <stdlib.h> struct TreeNode{ int Weight; HuffmanTree Left, Right; }; HuffmanTree Huffman(MinHeap H) { int i; HuffmanTree T; for( i = 1; i < H->ESize; 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; }
原文地址:https://www.cnblogs.com/biankun/p/9119655.html
时间: 2024-11-05 23:33:53