Tree/HuffmanTree.c
HFTree* initTree(int* weight,  int length) {
    HFTree* T = (HFTree*)malloc(sizeof(HFTree));
    T -> data = (TreeNode*)malloc(sizeof(TreeNode) * (2 * length - 1));
    T -> length = length;
    for (int i = 0; i < length; i++) {
        T -> data[i].weight = weight[i];
        T -> data[i].parent = 0;
        T -> data[i].lchild = -1;
        T -> data[i].rchild = -1;
    }
    return T;
}
/**
 * init huffman tree
 * @param weight the pointer of weight sequence
 * @param length the lenght of weight sequence
 * @return the pointer of huffman tree
 */
init huffman tree
@param weight the pointer of weight sequence
@param length the lenght of weight sequence
@return the pointer of huffman tree
init huffman tree @param weight the pointer of weight sequence @param length the lenght of weight sequence @return the pointer of huffman tree
HFTree* initTree(int* weight,  int length) {
    HFTree* T = (HFTree*)malloc(sizeof(HFTree));
    T -> data = (TreeNode*)malloc(sizeof(TreeNode) * (2 * length - 1));
    T -> length = length;
    for (int i = 0; i < length; i++) {
        T -> data[i].weight = weight[i];
        T -> data[i].parent = 0;
        T -> data[i].lchild = -1;
        T -> data[i].rchild = -1;
    }
    return T;
}
HFTree * initTree ( int * weight , int length ) { HFTree * T = ( HFTree * ) malloc ( sizeof ( HFTree ) ) ; T -> data = ( TreeNode * ) malloc ( sizeof ( TreeNode ) * ( 2 * length - 1 ) ) ; T -> length = length ; for ( int i = 0 ; i < length ; i ++ ) { T -> data [ i ] . weight = weight [ i ] ; T -> data [ i ] . parent = 0 ; T -> data [ i ] . lchild = -1 ; T -> data [ i ] . rchild = -1 ; } return T ; }
init huffman tree
 @param weight the pointer of weight sequence
 @param length the lenght of weight sequence
 @return the pointer of huffman tree
init huffman tree @param weight the pointer of weight sequence @param length the lenght of weight sequence @return the pointer of huffman tree