RootishArrayStack: A Space-Efficient Array Stack
Explore the RootishArrayStack, a space-efficient array-based stack that stores elements in blocks with minimal unused space. Understand its structure, how to calculate element positions within blocks, and perform key operations such as get, set, add, and remove efficiently.
We'll cover the following...
The data structures that store their data in one or two arrays and they avoid resizing these arrays too often, the arrays frequently are not very full. For example, immediately after a resize() operation on an ArrayStack, the backing array is only half full. Even worse, there are times when only one-third of it contains data.
Visual demonstration
A sequence of add(i, x) and remove(i) operations on a RootishArrayStack is illustrated below. Arrows denote elements being copied.
In this lesson, we discuss the RootishArrayStack data structure, that addresses the problem of wasted space. The RootishArrayStack stores elements using arrays. In these arrays, at most array locations are unused at any time. All remaining array locations are used to store data. Therefore, these data structures waste at most space when storing elements.
A RootishArrayStack stores its elements in a list of arrays called blocks that are numbered . See the above slides. Block contains elements. Therefore, all blocks contain a total of
...