5.2哈夫曼树——哈夫曼树与哈夫曼编码

#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;
}

 

posted @ 2018-05-31 23:30  BianK  阅读(212)  评论(0编辑  收藏  举报