Tree/HuffmanTree.c
void createHFTree(HFTree* T) {
    int* res;
    int min;
    int secondMin;
    int length = T -> length * 2 - 1;
    for (int i = T -> length; i < length; i++) {
        res = selectMin(T);
        min = res[0];
        secondMin = res[1];
        T -> data[i].weight = T -> data[min].weight + T -> data[secondMin].weight;
        T -> data[i].lchild = min;
        T -> data[i].rchild = secondMin;
        T -> data[i].parent = 0;
        T -> data[min].parent = i;
        T -> data[secondMin].parent = i;
        T -> length ++;
    }
}
/**
 * createt huffman tree
 * @param T the pointer of huffman tree
 */
createt huffman tree
@param T the pointer of huffman tree
createt huffman tree @param T the pointer of huffman tree
void createHFTree(HFTree* T) {
    int* res;
    int min;
    int secondMin;
    int length = T -> length * 2 - 1;
    for (int i = T -> length; i < length; i++) {
        res = selectMin(T);
        min = res[0];
        secondMin = res[1];
        T -> data[i].weight = T -> data[min].weight + T -> data[secondMin].weight;
        T -> data[i].lchild = min;
        T -> data[i].rchild = secondMin;
        T -> data[i].parent = 0;
        T -> data[min].parent = i;
        T -> data[secondMin].parent = i;
        T -> length ++;
    }
}
void createHFTree ( HFTree * T ) { int * res ; int min ; int secondMin ; int length = T -> length * 2 - 1 ; for ( int i = T -> length ; i < length ; i ++ ) { res = selectMin ( T ) ; min = res [ 0 ] ; secondMin = res [ 1 ] ; T -> data [ i ] . weight = T -> data [ min ] . weight + T -> data [ secondMin ] . weight ; T -> data [ i ] . lchild = min ; T -> data [ i ] . rchild = secondMin ; T -> data [ i ] . parent = 0 ; T -> data [ min ] . parent = i ; T -> data [ secondMin ] . parent = i ; T -> length ++ ; } }
createt huffman tree
 @param T the pointer of huffman tree
createt huffman tree @param T the pointer of huffman tree