Recall & Review
beginner
What is a Stack and how does it work?
A Stack is a data structure that works like a stack of plates. You add (push) and remove (pop) items only from the top. It follows Last In, First Out (LIFO) order.
Click to reveal answer
beginner
What is a Queue and how does it work?
A Queue is a data structure like a line at a store. You add (enqueue) items at the back and remove (dequeue) items from the front. It follows First In, First Out (FIFO) order.
Click to reveal answer
intermediate
When should you use a Stack?
Use a Stack when you need to reverse things, track recent actions, or handle nested tasks. Examples: undo buttons, backtracking, expression evaluation.
Click to reveal answer
intermediate
When should you use a Queue?
Use a Queue when order matters and you want to process items in the order they arrive. Examples: task scheduling, breadth-first search, printer queues.
Click to reveal answer
beginner
What is the main difference between Stack and Queue?
Stack removes the most recent item added (LIFO), while Queue removes the oldest item added (FIFO). This difference decides when to use each.
Click to reveal answer
Which data structure follows Last In, First Out (LIFO)?
✗ Incorrect
Stack follows LIFO, meaning the last item added is the first to be removed.
Which data structure is best for processing tasks in the order they arrive?
✗ Incorrect
Queue processes items in First In, First Out (FIFO) order, so tasks are handled in arrival order.
Which of these is a common use case for a Stack?
✗ Incorrect
Undo features use Stack to reverse recent actions (LIFO).
What operation adds an item to a Queue?
✗ Incorrect
Enqueue adds an item to the back of the Queue.
Which data structure would you use for breadth-first search (BFS)?
✗ Incorrect
BFS uses Queue to explore nodes level by level in FIFO order.
Explain the main difference between a Stack and a Queue and give one example use case for each.
Think about how items are added and removed in each.
You got /3 concepts.
Describe a real-life situation where using a Queue is better than a Stack.
Imagine waiting in line at a store.
You got /3 concepts.