Summary
In this paper we determine the number of binary trees with n leaves which can be evaluated optimally with less than or equal to k registers. Furthermore we obtain the result that this number is equal to the number of the binary trees with n leaves, using for traversal a maximum size of stack less than or equal to 2k+1−1. This fact is only a connection between the numbers of the trees and not between the sets of the trees. We compute also the average number ¯R(n) of registers needed to evaluate a binary tree optimally. We get for all ɛ>0: \(\bar R(n + 1) = 1d(\sqrt {n)} + C + F(n) + O(n^{ - 0.5 + \varepsilon } )\)where C = 0.82574... is a constant and F(n) is a function with F(n) = F(4n) for all n>0 and −0.574<F(n)< −0.492.
Similar content being viewed by others
References
Chandrasekharan, K.: Arithmetical Functions, Band 167. Springer-Verlag 1970
deBruijn, N.G., Knuth, D.E., Rice, S.O.: The average height of planted plane trees. In: Graph Theory and Computing, (R.C. Read, Ed.), pp. 15–22. New York-London: Ac. Press 1972
deBruijn, N.G.: On Mahler's partition problem. Koninklijke Nederlandsche Akademie van Wetenschappen, Proceedings Vol. LI, No. 6, 659–669 (1948)
Kemp, R.: The average number of registers needed to evaluate a binary tree optimally. Technical Report A77/04, Universität des Saarlandes, Saarbrücken, 1977
Nakata, I.: On compiling algorithms for arithmetic expressions. Comm. ACM 10, 492–494 (1967)
Sethi, R., Ullman, J.D.: The generation of optimal code for arithmetic expressions. JACM 17, 715–728 (1970)
Author information
Authors and Affiliations
Additional information
After finishing this paper, the author was informed, that P. Flajolet, J.C. Raoult and J. Vuillemin have recently obtained rather similar results by different methods
Rights and permissions
About this article
Cite this article
Kemp, R. The average number of registers needed to evaluate a binary tree optimally. Acta Informatica 11, 363–372 (1979). https://doi.org/10.1007/BF00289094
Received:
Issue Date:
DOI: https://doi.org/10.1007/BF00289094