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.
Similar content being viewed by others
References
Adler, M., Heeringa, B.: Approximating optimal binary decision trees. In: Proc. APPROX-RANDOM’08. LNCS, vol. 5171, pp. 1–9. Springer, Berlin (2008)
Baer, M.B.: Alphabetic coding with exponential costs. Inf. Process. Lett. 110(4), 139–142 (2010)
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)
Carmo, R., Donadelli, J., Kohayakawa, Y., Sany Laber, E.: Searching in random partially ordered sets. Theor. Comput. Sci. 321(1), 41–57 (2004)
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)
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)
Garey, M.R.: Optimal binary search trees with restricted maximal depth. SIAM J. Comput. 3(2), 101–110 (1974)
Garsia, A.M., Wachs, M.L.: A new algorithm for minimum cost binary trees. SIAM J. Comput. 6(4), 622–642 (1977)
Gilbert, E.N., Moore, E.F.: Variable-length binary encodings. Bell Syst. Tech. J. 38, 933–966 (1959)
Gotlieb, L.: Optimal multi-way search trees. SIAM J. Comput. 10(3), 422–433 (1981)
Hu, T.C.: A new proof of the T-C algorithm. SIAM J. Appl. Math. 25(1), 83–94 (1973)
Hu, T.C., Tucker, A.C.: Optimal computer search trees and variable-length alphabetical codes. SIAM J. Appl. Math. 21(4), 514–532 (1971)
Hu, T.C., Kleitman, D.J., Tamaki, J.K.: Binary trees optimum under various criteria. SIAM J. Appl. Math. 37(2), 246–256 (1979)
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)
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)
Itai, A.: Optimal alphabetic trees. SIAM J. Comput. 5(1), 9–18 (1976)
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)
Karp, R.M.: Reducibility among combinatorial problems. In: Miller, R.E., Thatcher, T.W. (eds.) Complexity of Computer Computations. Plenum Press, New York (1972)
Karpinski, M., Larmore, L.L., Rytter, W.: Correctness of constructing optimal alphabetic trees revisited. Theor. Comput. Sci. 180, 309–324 (1997)
Klawe, M., Mumey, B.: Upper and lower bounds on constructing alphabetic binary trees. In: Proc. SODA’93, pp. 185–193 (1993)
Knuth, D.E.: Optimum binary search trees. Acta Inform. 1, 14–25 (1971)
Kraft, L.G.: A device for quantizing, grouping, and coding amplitude modulated pulses. Master’s thesis, Massachusetts Institute of Technology (1949)
Larmore, L.L.: Height restricted optimal binary trees. SIAM J. Comput. 16(6), 1115–1123 (1987)
Larmore, L.L., Hirschberg, D.S.: Length-limited coding. In: Proc. SODA’90, pp. 310–318 (1990)
Larmore, L.L., Przytycka, T.M.: A fast algorithm for optimum height-limited alphabetic binary trees. SIAM J. Comput. 23, 1283–1312 (1994)
Mozes, S., Onak, K., Weimann, O.: Finding an optimal tree searching strategy in linear time. In: Proc. SODA’08, pp. 1096–1105 (2008)
Wessner, R.L.: Optimal alphabetic search trees with restricted maximal height. Inf. Process. Lett. 4(4), 90–94 (1976)
Yeung, R.W.: Alphabetic codes revisited. IEEE Trans. Inf. Theory 37(3), 564–572 (1991)
Zhao, L., Nagamochi, H., Ibaraki, T.: Greedy splitting algorithms for approximating multiway partition problems. Math. Program. 102, 167–183 (2005)
Acknowledgements
We wish to thank Sebastian Kamprath for a helpful comment regarding the presentation of Sect. 2.1.
Author information
Authors and Affiliations
Corresponding author
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
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
Received:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s00453-013-9755-6