A Hierarchical Statistical Algorithm for Obtaining Weighted Path Length
The huffman binary tree is an optimal binary tree,which is the shortest binary tree with weight path length.In order to minimize the weighted path length of a binary tree,a principle should be followed when con-structing a Huffman tree,that is,the node with greater weight is closer to the root of the tree.Therefore,each time we need to filter out the two nodes with the smallest value according to the weight value of each node,and then build a binary tree.There are certain rules for constructing a binary tree,but to determine whether it is the optimal binary tree,it must be determined by calculating its WPL value.Therefore,it is necessary to design a special algo-rithm to calculate WPL to test which is the minimum value of the weighted path length of the binary tree.In this pa-per,the hierarchical statistical algorithm is used to search the leaf node with weight by preorder traversal to obtain the WPL value,which provides the basis for the construction of Huffman tree.