Recall & Review
beginner
What is a stack in data structures?
A stack is a collection that follows Last In, First Out (LIFO) order, where the last element added is the first one to be removed.
Click to reveal answer
beginner
What are the two main operations of a stack?
The two main operations are push (to add an element) and pop (to remove the top element).
Click to reveal answer
beginner
In stack implementation using an array, what does the 'top' variable represent?
The 'top' variable stores the index of the last added element in the array, indicating the current top of the stack.
Click to reveal answer
intermediate
What happens when you try to push an element into a full stack implemented with an array?
This situation is called stack overflow. It means no more elements can be added because the array is full.
Click to reveal answer
beginner
How do you check if a stack implemented using an array is empty?
If the 'top' variable is -1, it means the stack is empty because no elements have been added yet.
Click to reveal answer
What does the 'pop' operation do in a stack?
✗ Incorrect
The 'pop' operation removes the top element from the stack.
What is the initial value of 'top' in an empty stack implemented using an array?
✗ Incorrect
The 'top' is set to -1 to indicate the stack is empty.
What condition indicates stack overflow in array implementation?
✗ Incorrect
When 'top' reaches array size - 1, the stack is full and overflow occurs.
Which data structure principle does a stack follow?
✗ Incorrect
Stack follows Last In, First Out (LIFO) principle.
What happens if you pop from an empty stack?
✗ Incorrect
Popping from an empty stack causes stack underflow, meaning no elements to remove.
Explain how to implement a stack using an array and how push and pop operations work.
Think about how you add and remove plates from a stack.
You got /5 concepts.
Describe what stack overflow and stack underflow mean in the context of array-based stack implementation.
Consider what happens if you add too many or remove too many items.
You got /4 concepts.
