Resizable Arrays in Optimal Time and Space

  • Authors:
  • Andrej Brodnik;Svante Carlsson;Erik D. Demaine;J. Ian Munro;Robert Sedgewick

  • Affiliations:
  • -;-;-;-;-

  • Venue:
  • WADS '99 Proceedings of the 6th International Workshop on Algorithms and Data Structures
  • Year:
  • 1999

Quantified Score

Hi-index 0.00

Visualization

Abstract

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.