Recall & Review
beginner
What is a stack in data structures?
A stack is a collection where elements are added and removed from only one end called the top. It follows the Last In, First Out (LIFO) principle.
Click to reveal answer
beginner
Explain the LIFO principle in simple terms.
LIFO means the last item you put in is the first one you take out, like a stack of plates where you take the top plate first.
Click to reveal answer
beginner
What are the two main operations of a stack?
The two main operations are push (to add an item on top) and pop (to remove the top item).
Click to reveal answer
intermediate
What happens if you try to pop from an empty stack?
This is called underflow. It means there is no item to remove because the stack is empty.
Click to reveal answer
intermediate
How does a stack differ from a queue?
A stack uses LIFO (last in, first out), while a queue uses FIFO (first in, first out). In a stack, you remove the last added item first; in a queue, you remove the oldest item first.
Click to reveal answer
Which operation adds an element to the top of a stack?
✗ Incorrect
Push adds an element to the top of the stack.
What does LIFO stand for in the context of stacks?
✗ Incorrect
LIFO means the last element added is the first one removed.
If you pop an element from a stack, which element do you remove?
✗ Incorrect
Pop removes the top element from the stack.
What is the term for trying to pop from an empty stack?
✗ Incorrect
Underflow happens when popping from an empty stack.
Which data structure follows FIFO instead of LIFO?
✗ Incorrect
Queue follows FIFO (first in, first out).
Describe how a stack works and explain the LIFO principle with a real-life example.
Think about how you add and remove items from a pile.
You got /3 concepts.
List and explain the main operations of a stack and what happens during underflow.
Focus on adding/removing items and empty stack behavior.
You got /4 concepts.
