Recall & Review
beginner
What is a queue in data structures?
A queue is a collection where elements are added at one end and removed from the other, following the First-In-First-Out (FIFO) principle.
Click to reveal answer
beginner
What does the enqueue operation do in a queue?
Enqueue adds an element to the back (end) of the queue.
Click to reveal answer
beginner
What does the dequeue operation do in a queue?
Dequeue removes and returns the element at the front (start) of the queue.
Click to reveal answer
beginner
Why is the queue called FIFO?
Because the first element added is the first one to be removed, like a line where the first person in line is served first.
Click to reveal answer
intermediate
What happens if you try to dequeue from an empty queue?
It usually causes an error or returns a special value indicating the queue is empty, because there is nothing to remove.
Click to reveal answer
Which end of the queue does enqueue add an element to?
✗ Incorrect
Enqueue always adds elements to the back of the queue.
What principle does a queue follow?
✗ Incorrect
Queues follow FIFO, meaning the first element added is the first removed.
What does dequeue do?
✗ Incorrect
Dequeue removes the element at the front of the queue.
If a queue is empty, what happens when you try to dequeue?
✗ Incorrect
Dequeue on an empty queue usually causes an error or returns a special value indicating emptiness.
Which real-life example best represents a queue?
✗ Incorrect
People waiting in line is a classic example of a queue following FIFO.
Explain the enqueue and dequeue operations in a queue with a real-life example.
Think about how people join and leave a line.
You got /4 concepts.
What happens if you try to dequeue from an empty queue and why is it important to handle this case?
Consider what happens when you try to take something from an empty container.
You got /3 concepts.