A simple, efficient, and flexible implementation of flexible arrays
- 180 Downloads
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.
Unable to display preview. Download preview PDF.
- 1.Braun W. and Rem M., A logarithmic implementation of flexible arrays, Memorandum MR83/4, University of Technology Eindhoven, 1983.Google Scholar
- 2.Challab D.J., Implementation of flexible arrays using balanced trees, The Computer Journal, vol. 34, no. 5. 1991, pp 386–396.Google Scholar
- 3.Dijkstra, E. W., A discipline of programming, Prentice Hall, Englewood Cliffs, 1976.Google Scholar
- 4.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.Google Scholar
- 5.Kaldewaij A., Programming, The derivation of algorithms, Prentice Hall International Series in Computer Science, 1990, pp 67–69Google Scholar
- 6.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.Google Scholar
- 7.Knuth, D.E., The art of computer programming 3: Sorting and searching, Addison-Wesley, Reading, Mass. (1973).Google Scholar
- 8.Lewis H.R. and Denenberg L., Data structures and their algorithms, Harper Collins Publishers, 1991.Google Scholar
- 9.Lindsey, C.H., ALGOL-68 with fewer tears, Algol Bulletin 28 (1968), Science Reference Library, London UK.Google Scholar
- 10.Overmars M.H., Dynamization of order decomposable set problems, J. Algorithms 2 (1981), pp 245–260.Google Scholar
- 11.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.Google Scholar
- 12.Wood D., Data structures, algorithms, and performance, Addison-Wesley (1993).Google Scholar