Recall & Review
beginner Click to reveal answer
What is a dequeue in data structures?
A dequeue (double-ended queue) is a data structure where elements can be added or removed from both the front and the rear ends.
beginner Click to reveal answer
Name the two main operations to remove elements in a dequeue.
The two main removal operations are removeFront() and removeRear(), which remove elements from the front and rear ends respectively.
beginner Click to reveal answer
What happens if you try to remove an element from an empty dequeue?
Trying to remove an element from an empty dequeue usually returns
null or undefined or throws an error, depending on the implementation.intermediate Click to reveal answer
In a dequeue, which operation is faster: removing from front or rear?
Both removing from the front and rear are typically O(1) operations, meaning they take constant time.
intermediate Click to reveal answer
Show a simple TypeScript method signature for removing an element from the front of a dequeue.
A simple method signature could be:
This means it returns the removed element of type
removeFront(): T | nullThis means it returns the removed element of type
T or null if empty.What does the dequeue operation
removeRear() do?✗ Incorrect
removeRear() removes an element from the rear end of the dequeue.If a dequeue is empty, what should
removeFront() return?✗ Incorrect
Removing from an empty dequeue should return null, undefined, or throw an error.
Which of these is NOT a valid dequeue operation?
✗ Incorrect
peekMiddle() is not a standard dequeue operation.What is the time complexity of removing an element from the front of a dequeue?
✗ Incorrect
Removing from the front of a dequeue is a constant time operation, O(1).
Which data structure is most similar to a dequeue?
✗ Incorrect
A dequeue is like a queue but allows insertion and removal from both ends.
Explain how the removeFront() and removeRear() operations work in a dequeue.
Think about which end of the dequeue each operation affects.
You got /4 concepts.
Describe the advantages of using a dequeue over a simple queue for removal operations.
Consider the ends where you can add or remove elements.
You got /4 concepts.
