Recall & Review
beginner
What is a Double Ended Queue (Deque)?
A Double Ended Queue, or Deque, is a data structure where elements can be added or removed from both the front and the back.
Click to reveal answer
beginner
Name two main operations you can perform on a Deque.
You can add elements (called enqueue) and remove elements (called dequeue) from both the front and the back ends.
Click to reveal answer
beginner
How does a Deque differ from a regular Queue?
A regular Queue allows adding at the back and removing from the front only. A Deque allows adding and removing from both ends.
Click to reveal answer
intermediate
What is the output after these operations on an empty Deque: add_front(1), add_back(2), remove_front(), add_back(3)?
After add_front(1): 1<br>After add_back(2): 1 -> 2<br>After remove_front(): 2<br>After add_back(3): 2 -> 3
Click to reveal answer
beginner
Why is a Deque useful in real life?
Because it lets you add or remove items from both ends, it is like a line where people can enter or leave from front or back, useful for tasks like undo/redo or sliding windows.
Click to reveal answer
Which operation is NOT possible in a Deque?
✗ Incorrect
Deques allow adding/removing only at front or back, not in the middle.
What is the state of the Deque after add_back(5) on an empty Deque?
✗ Incorrect
Adding 5 at back on empty Deque results in Deque with one element: 5.
If a Deque has elements 3 -> 4 -> 5, what is the result after remove_back()?
✗ Incorrect
Removing from back removes 5, leaving 3 -> 4.
Which real-life example best matches a Deque?
✗ Incorrect
Deque allows adding/removing from both ends, like a line with two open doors.
What is the time complexity for adding or removing elements at either end of a Deque?
✗ Incorrect
Deque operations at front or back are done in constant time O(1).
Explain what a Double Ended Queue (Deque) is and how it works.
Think about a line where people can enter or leave from front or back.
You got /3 concepts.
Describe a real-life situation where using a Deque would be helpful and why.
Consider undo/redo or sliding window problems.
You got /3 concepts.