Bird
0
0
DSA Cprogramming~5 mins

Dynamic Stack Using Resizable Array in DSA C - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AWhen the stack has exactly one element
BWhen the stack is full or too empty
COnly when the stack is full
DOnly when the stack is empty
What is the usual factor by which the array size is increased during resizing?
ADoubled
BTripled
CIncreased by one
DHalved
What is the main advantage of using a dynamic stack over a fixed-size stack?
AIt is slower
BIt uses less memory always
CIt never needs resizing
DIt can handle more elements without running out of space
What happens to elements during resizing of the stack's array?
AThey are deleted
BThey stay in the old array
CThey are copied to the new array
DThey are reversed
What is the amortized time complexity of push operation in a dynamic stack?
AO(1)
BO(n)
CO(log n)
DO(n^2)
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.