Skip to main content
Log in

On the Huffman and Alphabetic Tree Problem with General Cost Functions

  • Published:
Algorithmica Aims and scope Submit manuscript

Abstract

We address generalized versions of the Huffman and Alphabetic Tree Problem where the cost caused by each individual leaf i, instead of being linear, depends on its depth in the tree by an arbitrary function. The objective is to minimize either the total cost or the maximum cost among all leaves. We review and extend the known results in this direction and devise a number of new algorithms and hardness proofs.

It turns out that the Dynamic Programming approach for the Alphabetic Tree Problem can be extended to arbitrary cost functions, resulting in a time O(n 4) optimal algorithm using space O(n 3). We identify classes of cost functions where the well-known trick to reduce the runtime by a factor of n via a “monotonicity” property can be applied.

For the generalized Huffman Tree Problem we show that even the k-ary version can be solved by a generalized version of the Coin Collector Algorithm of Larmore and Hirschberg (in Proc. SODA’90, pp. 310–318, 1990) when the cost functions are nondecreasing and convex. Furthermore, we give an O(n 2logn) algorithm for the worst case minimization variants of both the Huffman and Alphabetic Tree Problem with nondecreasing cost functions.

Investigating the limits of computational tractability, we show that the Huffman Tree Problem in its full generality is inapproximable unless P = NP, no matter if the objective function is the sum of leaf costs or their maximum. The alphabetic version becomes NP-hard when the leaf costs are interdependent.

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.

Fig. 1
Fig. 2
Fig. 3
Fig. 4

Similar content being viewed by others

References

  1. Adler, M., Heeringa, B.: Approximating optimal binary decision trees. In: Proc. APPROX-RANDOM’08. LNCS, vol. 5171, pp. 1–9. Springer, Berlin (2008)

    Google Scholar 

  2. Baer, M.B.: Alphabetic coding with exponential costs. Inf. Process. Lett. 110(4), 139–142 (2010)

    Article  MATH  MathSciNet  Google Scholar 

  3. Bose, P., Douïeb, K.: Should static search trees ever be unbalanced? In: Proc. ISAAC’10. LNCS, vol. 6506, pp. 109–120. Springer, Berlin (2010)

    Google Scholar 

  4. Carmo, R., Donadelli, J., Kohayakawa, Y., Sany Laber, E.: Searching in random partially ordered sets. Theor. Comput. Sci. 321(1), 41–57 (2004)

    Article  MATH  Google Scholar 

  5. Chakaravarthy, V.T., Pandit, V., Roy, S., Awasthi, P., Mohania, M.K.: Decision trees for entity identification: approximation algorithms and hardness results. In: Proc. PODS’07, pp. 53–62 (2007)

    Google Scholar 

  6. Chakaravarthy, V.T., Pandit, V., Roy, S., Sabharwal, Y.: Approximating decision trees with multiway branches. In: Proc. ICALP’09. LNCS, vol. 5555, pp. 210–221. Springer, Berlin (2009)

    Google Scholar 

  7. Garey, M.R.: Optimal binary search trees with restricted maximal depth. SIAM J. Comput. 3(2), 101–110 (1974)

    Article  MATH  MathSciNet  Google Scholar 

  8. Garsia, A.M., Wachs, M.L.: A new algorithm for minimum cost binary trees. SIAM J. Comput. 6(4), 622–642 (1977)

    Article  MATH  MathSciNet  Google Scholar 

  9. Gilbert, E.N., Moore, E.F.: Variable-length binary encodings. Bell Syst. Tech. J. 38, 933–966 (1959)

    Article  MathSciNet  Google Scholar 

  10. Gotlieb, L.: Optimal multi-way search trees. SIAM J. Comput. 10(3), 422–433 (1981)

    Article  MATH  MathSciNet  Google Scholar 

  11. Hu, T.C.: A new proof of the T-C algorithm. SIAM J. Appl. Math. 25(1), 83–94 (1973)

    Article  MATH  MathSciNet  Google Scholar 

  12. Hu, T.C., Tucker, A.C.: Optimal computer search trees and variable-length alphabetical codes. SIAM J. Appl. Math. 21(4), 514–532 (1971)

    Article  MATH  MathSciNet  Google Scholar 

  13. Hu, T.C., Kleitman, D.J., Tamaki, J.K.: Binary trees optimum under various criteria. SIAM J. Appl. Math. 37(2), 246–256 (1979)

    Article  MATH  MathSciNet  Google Scholar 

  14. Hu, T.C., Larmore, L.L., Morgenthaler, J.D.: Optimal integer alphabetic trees in linear time. In: Proc. ESA’05. LNCS, vol. 3669, pp. 226–237. Springer, Berlin (2005)

    Google Scholar 

  15. Huffman, D.A.: A method for the construction of minimum-redundancy codes. In: Proc. the Institute of Radio Engineers, vol. 40, pp. 1098–1101 (1952)

    Google Scholar 

  16. Itai, A.: Optimal alphabetic trees. SIAM J. Comput. 5(1), 9–18 (1976)

    Article  MATH  MathSciNet  Google Scholar 

  17. Jacobs, T., Cicalese, F., Laber, E., Molinaro, M.: On the complexity of searching in trees: average-case minimization. In: Proc. ICALP’10. LNCS, vol. 6198, pp. 527–539. Springer, Berlin (2010)

    Google Scholar 

  18. Karp, R.M.: Reducibility among combinatorial problems. In: Miller, R.E., Thatcher, T.W. (eds.) Complexity of Computer Computations. Plenum Press, New York (1972)

    Google Scholar 

  19. Karpinski, M., Larmore, L.L., Rytter, W.: Correctness of constructing optimal alphabetic trees revisited. Theor. Comput. Sci. 180, 309–324 (1997)

    Article  MATH  MathSciNet  Google Scholar 

  20. Klawe, M., Mumey, B.: Upper and lower bounds on constructing alphabetic binary trees. In: Proc. SODA’93, pp. 185–193 (1993)

    Google Scholar 

  21. Knuth, D.E.: Optimum binary search trees. Acta Inform. 1, 14–25 (1971)

    Article  MATH  Google Scholar 

  22. Kraft, L.G.: A device for quantizing, grouping, and coding amplitude modulated pulses. Master’s thesis, Massachusetts Institute of Technology (1949)

  23. Larmore, L.L.: Height restricted optimal binary trees. SIAM J. Comput. 16(6), 1115–1123 (1987)

    Article  MATH  MathSciNet  Google Scholar 

  24. Larmore, L.L., Hirschberg, D.S.: Length-limited coding. In: Proc. SODA’90, pp. 310–318 (1990)

    Google Scholar 

  25. Larmore, L.L., Przytycka, T.M.: A fast algorithm for optimum height-limited alphabetic binary trees. SIAM J. Comput. 23, 1283–1312 (1994)

    Article  MATH  MathSciNet  Google Scholar 

  26. Mozes, S., Onak, K., Weimann, O.: Finding an optimal tree searching strategy in linear time. In: Proc. SODA’08, pp. 1096–1105 (2008)

    Google Scholar 

  27. Wessner, R.L.: Optimal alphabetic search trees with restricted maximal height. Inf. Process. Lett. 4(4), 90–94 (1976)

    Article  MATH  MathSciNet  Google Scholar 

  28. Yeung, R.W.: Alphabetic codes revisited. IEEE Trans. Inf. Theory 37(3), 564–572 (1991)

    Article  MathSciNet  Google Scholar 

  29. Zhao, L., Nagamochi, H., Ibaraki, T.: Greedy splitting algorithms for approximating multiway partition problems. Math. Program. 102, 167–183 (2005)

    Article  MATH  MathSciNet  Google Scholar 

Download references

Acknowledgements

We wish to thank Sebastian Kamprath for a helpful comment regarding the presentation of Sect. 2.1.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Hiroshi Fujiwara.

Additional information

The work was supported by KAKENHI (19700015, 23700014, and 23500014) and a fellowship within the Postdoc-Programme of the German Academic Exchange Service (DAAD).

A preliminary version of this paper has appeared in the proceedings of the 18th Annual European Symposium on Algorithms, 2010.

Rights and permissions

Reprints and permissions

About this article

Cite this article

Fujiwara, H., Jacobs, T. On the Huffman and Alphabetic Tree Problem with General Cost Functions. Algorithmica 69, 582–604 (2014). https://doi.org/10.1007/s00453-013-9755-6

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s00453-013-9755-6

Keywords

Navigation