Recall & Review
beginner
What is a dynamic stack using a resizable array?
A stack that can grow or shrink in size by resizing its underlying array when needed, allowing flexible storage without fixed limits.
Click to reveal answer
beginner
Why do we resize the array in a dynamic stack?
To add more space when the stack is full or reduce space when many elements are removed, optimizing memory use.
Click to reveal answer
intermediate
What happens during the push operation if the stack is full?
The array size is doubled, existing elements are copied to the new larger array, then the new element is added.
Click to reveal answer
intermediate
How does the pop operation affect the array size in a dynamic stack?
If the number of elements becomes much smaller than the array size (usually less than a quarter), the array size is halved to save space.
Click to reveal answer
intermediate
What is the time complexity of push and pop in a dynamic stack using a resizable array?
Amortized time complexity is O(1) for both push and pop, because resizing happens rarely and copying cost is spread out.
Click to reveal answer
What triggers the resizing of the array in a dynamic stack?
✗ Incorrect
The array resizes when full (to grow) or when too empty (to shrink).
What is the usual factor by which the array size is increased during resizing?
✗ Incorrect
The array size is usually doubled to balance between resizing frequency and memory use.
What is the main advantage of using a dynamic stack over a fixed-size stack?
✗ Incorrect
Dynamic stacks can grow as needed, unlike fixed-size stacks with limited capacity.
What happens to elements during resizing of the stack's array?
✗ Incorrect
Elements are copied to the new larger or smaller array to preserve the stack content.
What is the amortized time complexity of push operation in a dynamic stack?
✗ Incorrect
Push is O(1) amortized because resizing happens rarely and cost is spread out.
Explain how a dynamic stack resizes its array during push and pop operations.
Think about when the stack grows and shrinks.
You got /3 concepts.
Describe the benefits of using a dynamic stack with a resizable array compared to a fixed-size stack.
Consider memory and capacity.
You got /3 concepts.
