Efficient Generation of Optimal Prefix Code
- 1 April 1975
- journal article
- Published by Association for Computing Machinery (ACM) in Journal of the ACM
- Vol. 22 (2) , 202-214
- https://doi.org/10.1145/321879.321883
Abstract
ABSTRACrr. An algorithm for constructing an optimal prefix code of n eqmprobable words over r unequal cost coding letters is given. The discussion is in terms of rooted labeled trees. The algorithm consists of two parts. The first one is an extension algorithm which constructs a prefix code of n words. This code is either optimal or is a "good" approximation The second part is a mending algorithm which changes the code constructed by the extension algorithm into an optimal code in case it is not already optimal. The validity of the combined algorithm is proved and its structure is analyzed. The analysis leads to further improvement of the algorithm's efficiency. It is shown that the number of steps required is at mnst O(r.n.log n), if a heap data structure is used Alternatively, one can use a data structure of r queues, in which case the number of steps is bounded by O(r.n).Keywords
This publication has 3 references indexed in Scilit:
- Optimal variable length codes (arbitrary symbol cost and equal code word probability)Information and Control, 1971
- Algorithm 245: TreesortCommunications of the ACM, 1964
- AlgorithmsCommunications of the ACM, 1964