Recall & Review
beginner
What is a circular queue?
A circular queue is a type of queue where the last position is connected back to the first position to make a circle. It allows efficient use of space by reusing empty slots after dequeue operations.
Click to reveal answer
beginner
How do you check if a circular queue is full?
The circular queue is full when the next position of rear is equal to front. In formula: (rear + 1) % size == front.
Click to reveal answer
intermediate
What happens to front and rear pointers when you enqueue an element in a circular queue?
When enqueueing, rear moves forward by one position using (rear + 1) % size. If the queue was empty, front is set to 0.
Click to reveal answer
intermediate
How do you dequeue an element from a circular queue?
Remove the element at front, then move front forward by one using (front + 1) % size. If after dequeue front becomes equal to rear + 1 (mod size), reset both to -1 (empty queue).
Click to reveal answer
beginner
Why is a circular queue better than a simple linear queue using arrays?
A circular queue reuses empty spaces freed by dequeued elements, avoiding wasted space and the need to shift elements. A linear queue wastes space once rear reaches the end.
Click to reveal answer
What condition indicates that a circular queue is empty?
✗ Incorrect
The queue is empty when both front and rear are -1.
If the queue size is 5, front is 3, and rear is 1, is the queue full?
✗ Incorrect
Calculate (1 + 1) % 5 = 2, which is not equal to front (3), so queue is not full. Correct answer is No, so option A is wrong. Correct answer is C.
What is the formula to move rear pointer forward in a circular queue?
✗ Incorrect
Rear moves forward circularly using modulo operation.
After dequeuing the last element, what should front and rear be set to?
✗ Incorrect
Setting both to -1 indicates the queue is empty.
Why do we use modulo (%) operator in circular queue?
✗ Incorrect
Modulo helps wrap pointers back to start to form a circle.
Explain how enqueue and dequeue operations work in a circular queue using an array.
Think about how the pointers move in a circle.
You got /4 concepts.
Describe the advantages of using a circular queue over a simple linear queue implemented with arrays.
Consider what happens when the rear reaches the end of the array.
You got /4 concepts.
