Abstract
Flexible arrays can grow and shrink at both sides. Operations on flexible arrays are the usual ones: element inspection and assignment of a value to an array element. Additional operations are hiext, extending the array at its high end with an entry; loext, extension at the low end; hirem, removing the last element of the array; and lorem, removing the first element of the array.
It is shown how so-called leaf trees can be used to implement flexible arrays efficiently. The implementation is simple (no rotations are involved) and yields nicely shaped trees. The implementation is flexible, in the sense that a large class of additional operations, such as computation of the minimum and maximum of the array, can be easily added to the repertoire of operations without affecting time complexities. The standard flexible array operations take O(log n) time, where n is the size of the flexible array. Additional operations, such as minimum and maximum take O(1) time.
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Braun W. and Rem M., A logarithmic implementation of flexible arrays, Memorandum MR83/4, University of Technology Eindhoven, 1983.
Challab D.J., Implementation of flexible arrays using balanced trees, The Computer Journal, vol. 34, no. 5. 1991, pp 386–396.
Dijkstra, E. W., A discipline of programming, Prentice Hall, Englewood Cliffs, 1976.
Hoogerwoord, R.R., A logarithmic implementation of flexible arrays in Mathematics of Program Construction: second international conference, Oxford U.K., June 29–July 3, 1992: proceedings/R.S. Bird, C.C. Morgan, J.C.P. Woodcock, eds, LCNS 669, Springer-Verlag, Berlin Heidelberg 1993, pp 191–207.
Kaldewaij A., Programming, The derivation of algorithms, Prentice Hall International Series in Computer Science, 1990, pp 67–69
Kaldewaij A. and Dielissen V.J., Decomposable functions and leaf trees: a systematic approach, in Programming, concepts, methods and calculi: proceedings of the IFIP TC2/WG2.1/WG2.2/WG2.3 Working Conference on Programming Concepts, Methods and calculi (PROCOMET'94), San Miniato, Italy, 6–10 June 1994 / edited by Ernst-Rüdiger Olderog, Elsevier, Amsterdam, 1994, pp 3–17.
Knuth, D.E., The art of computer programming 3: Sorting and searching, Addison-Wesley, Reading, Mass. (1973).
Lewis H.R. and Denenberg L., Data structures and their algorithms, Harper Collins Publishers, 1991.
Lindsey, C.H., ALGOL-68 with fewer tears, Algol Bulletin 28 (1968), Science Reference Library, London UK.
Overmars M.H., Dynamization of order decomposable set problems, J. Algorithms 2 (1981), pp 245–260.
Wadler P., Linear types can change the world! in M. Broy, C.B. Jones (eds.), Programming concepts and methods, North-Holland, Amsterdam (1990), pp 561–581.
Wood D., Data structures, algorithms, and performance, Addison-Wesley (1993).
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1995 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Dielissen, V.J., Kaldewaij, A. (1995). A simple, efficient, and flexible implementation of flexible arrays. In: Möller, B. (eds) Mathematics of Program Construction. MPC 1995. Lecture Notes in Computer Science, vol 947. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-60117-1_13
Download citation
DOI: https://doi.org/10.1007/3-540-60117-1_13
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-60117-3
Online ISBN: 978-3-540-49445-4
eBook Packages: Springer Book Archive