Hostname: page-component-586b7cd67f-2plfb Total loading time: 0 Render date: 2024-11-20T11:31:34.727Z Has data issue: false hasContentIssue false

Functional Pearls

Drawing trees

Published online by Cambridge University Press:  07 November 2008

Andrew J. Kennedy
Affiliation:
University of Cambridge Computer Laboratory, New Museums Site, Pembroke Street, Cambridge CB2 3QG, UK
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

This article describes the application of functional programming techniques to a problem previously studied by imperative programmers, that of drawing general trees automatically. We first consider the nature of the problem and the ideas behind its solution (due to Radack), independent of programming language implementation. We then describe a Standard ML program which reflects the structure of the abstract solution much better than an imperative language implementation. We conclude with an informal discussion on the correctness of the implementation and some changes which improve the algorithm's worst-case time complexity.

Type
Articles
Copyright
Copyright © Cambridge University Press 1996

References

Bird, R. and Wadler, P. (1988) Introduction to Functional Programming. Prentice Hall.Google Scholar
Gibbons, J. (1991) Algebras for Tree Algorithms. DPhil thesis, Oxford University Computing Laboratory.Google Scholar
Gibbons, J. (1996) Deriving tidy drawings of trees. J. Functional Programming. This issue.CrossRefGoogle Scholar
Milner, R., Tofte, M. and Harper, R. (1989) The Definition of Standard ML. MIT Press.Google Scholar
Paulson, L. C. (1991) ML for the Working Programmer. Cambridge University Press.Google Scholar
Radack, G. M. (1988) Tidy drawing of M-ary trees. Technical Report CES-88-24, Department of Computer Engineering and Science, Case Western Reserve University, Cleveland, OH, November.Google Scholar
Reingold, E. M. and Tilford, J. S. (1981) Tidier drawings of trees. IEEE Trans. Software Engineering, 7(2):223228, March.CrossRefGoogle Scholar
Vaucher, J. G. (1980) Pretty-printing of trees. Software—Practice and Experience, 10:553561.CrossRefGoogle Scholar
Walker, J. Q. II (1990) A node-positioning algorithm for general trees. Software—Practice and Experience, 20(7):685705, July.CrossRefGoogle Scholar
Wetherell, C. and Shannon, A. (1979) Tidy drawings of trees. IEEE Trans. Software Engineering, 5(5):514520, September.CrossRefGoogle Scholar
Submit a response

Discussions

No Discussions have been published for this article.