摘要
针对哈夫曼编码需要用到指针和结构体而导致使用受到限制的问题,提出一种不用指针和结构体也能进行哈夫曼编码的算法。算法以哈夫曼编码的编码原理为基础,先自底向上得到各个中间结点的双亲结点和孩子结点,然后自顶向下得到各个结点的二进制码字,最后得到的叶子结点的码字就是哈夫曼编码。由于所设计的哈夫曼编码算法只需要使用一维数组即可以实现,故对完成编码的计算机语言没有任何限制。算例仿真表明,使用三个一维数组即可实现任何事件的哈夫曼编码。
According to the application limitation of Huffman encoding due to the need of using the pointer and structure body,a Huffman encoding algorithm without the pointer and structure body was presented in this paper.The algorithm is based on the encoding principle of Huffman encoding. First,from the bottom up to the top it can get the parent node and child nodes of every intermediate node. Second,from the top down to the bottom it can get the binary code of each node. Finally,codewords of all the leaf nodes consist of the Huffman encoding. The Huffman encoding algorithm can be achieved only by using a one-dimensional in this paper,so the completion of the encoding doesn't depend on any computer language. The simulation results show that three one-dimension arrays can realize the Huffman encoding of any event.
出处
《武汉轻工大学学报》
2016年第1期88-91,共4页
Journal of Wuhan Polytechnic University
基金
国家自然科学基金资助项目(61179032)
关键词
哈夫曼编码
中间结点
码字
叶子结点
Huffman coding
intermediate node
code word
Leaf node