Skip to main content
Log in

A Fast Algorithm for Adaptive Prefix Coding

  • Published:
Algorithmica Aims and scope Submit manuscript

Abstract

In this paper we present a new algorithm for adaptive prefix coding. Our algorithm encodes a text S of m symbols in O(m) time, i.e., in O(1) amortized time per symbol. The length of the encoded string is bounded above by (H+1)m+O(nlog 2 m) bits where n is the alphabet size and H is the entropy.

This is the first algorithm that adaptively encodes a text in O(m) time and achieves an almost optimal bound on the encoding length in the worst case. Besides that, our algorithm does not depend on an explicit code tree traversal.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. Andersson, A., Miltersen, P.B., Thorup, M.: Fusion trees can be implemented with AC0 instructions only. Theor. Comput. Sci. 215, 337–344 (1999)

    Article  MATH  MathSciNet  Google Scholar 

  2. Connell, J.B.: A Huffman-Shannon-Fano code. Proc. IEEE 61, 1046–1047 (1973)

    Article  Google Scholar 

  3. Capocelli, R.M., De Santis, A.: New bounds on the redundancy of Huffman codes. IEEE Trans. Inf. Theory 37, 1095–1104 (1991)

    Article  MATH  Google Scholar 

  4. Faller, N.: An adaptive system for data compression. In: Proc. 7th Asilomar Conference on Circuits, Systems, and Computers, pp. 593–597 (1973)

  5. Fredman, M.L., Willard, D.E.: Surpassing the information theoretic bound with fusion trees. J. Comput. Syst. Sci. 47, 424–436 (1993)

    Article  MATH  MathSciNet  Google Scholar 

  6. Gagie, T.: Dynamic Shannon coding. In: Proc. the 12th European Symposium on Algorithms. LNCS, vol. 3221, pp. 359–370. Springer, Berlin (2004), see also Inf. Process. Lett. 102, 113–117 (2007)

    Google Scholar 

  7. Gallager, R.G.: Variations on a theme by Huffman. IEEE Trans. Inf. Theory 24, 668–674 (1978)

    Article  MATH  MathSciNet  Google Scholar 

  8. Golumbic, M.C.: Combinatorial merging. IEEE Trans. Comput. 25, 1164–1167 (1976)

    Article  MATH  MathSciNet  Google Scholar 

  9. Huffman, D.A.: A method for construction of minimum-redundancy codes. Proc. IRE 40, 1098–1101 (1952)

    Article  Google Scholar 

  10. Klein, S.T.: Skeleton trees for the efficient decoding of Huffman encoded texts. Inf. Retr. 3, 7–23 (2000). A preliminary version, Space- and time-efficient decoding with canonical Huffman trees, appeared in Proc. the 8th Annual Symposium on Combinatorial Pattern Matching. LNCS, vol. 1264, pp. 65–75 (1997).

    Article  Google Scholar 

  11. Knuth, D.E.: Dynamic Huffman coding. J. Algorithms 6, 163–180 (1985)

    Article  MATH  MathSciNet  Google Scholar 

  12. Lelewer, D.A., Hirschberg, D.S.: Data compression. ACM Comput. Surv. 19, 261–296 (1987)

    Article  MATH  Google Scholar 

  13. Milidiú, R.L., Laber, E.S., Pessoa, A.A.: Bounding the compression loss of the FGK algorithm. J. Algorithms 32, 195–211 (1999)

    Article  MATH  MathSciNet  Google Scholar 

  14. Moffat, A., Turpin, A.: On the implementation of minimum-redundancy prefix codes. IEEE Trans. Commun. 45, 1200–1207 (1997)

    Article  Google Scholar 

  15. Rueda, L., Oommen, B.J.: A fast and efficient nearly-optimal adaptive Fano coding scheme. Inf. Sci. 176, 1656–1683 (2006)

    Article  MATH  MathSciNet  Google Scholar 

  16. Shannon, C.E.: A mathematical theory of communication. Bell Syst. Techn. J. 27, 379–423 (1948)

    MATH  MathSciNet  Google Scholar 

  17. Shannon, C.E.: A mathematical theory of communication. Bell Syst. Techn. J. 27, 623–656 (1948)

    MathSciNet  Google Scholar 

  18. Schwartz, E.S., Kallick, B.: Generating a canonical prefix encoding. Commun. ACM 7, 166–169 (1964)

    Article  MATH  Google Scholar 

  19. Turpin, A., Moffat, A.: On-line adaptive canonical prefix coding with bounded compression loss. IEEE Trans. Inf. Theory 47, 88–98 (2001)

    Article  MATH  MathSciNet  Google Scholar 

  20. Vitter, J.S.: Design and analysis of dynamic Huffman codes. J. ACM 34, 825–845 (1987)

    MATH  MathSciNet  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Yakov Nekrich.

Additional information

A preliminary version of this paper appeared in the Proceedings of the 2006 IEEE International Symposium on Information Theory (ISIT 2006).

M. Karpinski’s work partially supported by a DFG grant, Max-Planck Research Prize, and IST grant 14036 (RAND-APX).

Y. Nekrich’s work partially supported by IST grant 14036 (RAND-APX).

Rights and permissions

Reprints and permissions

About this article

Cite this article

Karpinski, M., Nekrich, Y. A Fast Algorithm for Adaptive Prefix Coding. Algorithmica 55, 29–41 (2009). https://doi.org/10.1007/s00453-007-9140-4

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s00453-007-9140-4

Keywords

Navigation