Analysis of RootishArrayStack
Explore the advantage of using RootishArrayStack.
We'll cover the following...
Growing and shrinking
Note that, unlike the ArrayStack.resize()
operation, grow()
and shrink()
do not copy any data. They only allocate or free an array of size . In some environments, this takes only constant time, while in others, it may require time proportional to .
Press + to interact
We note that, immediately after a call to grow()
or shrink()
, the situation is clear. The final block is completely empty, and all other blocks are completely full. Another call to grow()
or shrink()
will not happen until at least ...
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy