RootishArrayStack: A Space-Efficient Array Stack
Discover the need of RootishArrayStack.
We'll cover the following...
The data structures that store their data in one or two arrays and 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
...
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy