Resizable Arrays in Optimal Time and Space
- 673 Downloads
We present simple, practical and efficient data structures for the fundamental problem of maintaining a resizable one-dimensional array, A[l..l + n − 1], of fixed-size elements, as elements are added to or removed from one or both ends. Our structures also support access to the element in position i. All operations are performed in constant time. The extra space (i.e., the space used past storing the n current elements) is O(√n) at any point in time. This is shown to be within a constant factor of optimal, even if there are no constraints on the time. If desired, each memory block can be made to have size 2k − c for a specified constant c, and hence the scheme works effectively with the buddy system. The data structures can be used to solve a variety of problems with optimal bounds on time and extra storage. These include stacks, queues, randomized queues, priority queues, and deques.
KeywordsLookup Table Data Block Priority Queue Memory Block Extra Space
Unable to display preview. Download preview PDF.
- 1.A. Brodnik. Computation of the least significant set bit. In Proceedings of the 2nd Electrotechnical and Computer Science Conference, Portoroz, Slovenia, 1993.Google Scholar
- 2.A. Brodnik, S. Carlsson, E. D. Demaine, J. I. Munro, and R. Sedgewick. Resizable arrays in optimal time and space. Technical Report CS-99-09, U. Waterloo, 1999.Google Scholar
- 5.M. T. Goodrich and J. G. Kloss II. Tiered vector: An efficient dynamic array for JDSL. This volume.Google Scholar
- 6.D. E. Knuth. The Art of Computer Programming. Addison-Wesley, 1968.Google Scholar
- 7.M. K. McKusick, K. Bostic, M. J. Karels, and J. S. Quarterman. The Design and Implementation of the 4.4 BSD Operating System. Addison-Wesley, 1996.Google Scholar
- 8.R. Motwani and P. Raghavan. Randomized Algorithms. Camb. Univ. Press, 1995.Google Scholar
- 9.W. H. Press, B. P. Flannery, S. A. Teukolsky, and W. T. Vetterling. Numerical Recipes in C: The Art of Scientific Computing. Camb. Univ. Press, 2nd ed., 1992.Google Scholar
- 10.R. Sedgewick. Algorithms in C. Addison-Wesley, 3rd ed., 1997.Google Scholar
- 11.B. Stroustrup. The C++ Programming Language. Addison-Wesley, 3rd ed., 1997.Google Scholar