Circular Queues Flashcards
(2 cards)
1
Q
adding an item to a circular queue
A
- Check the queue is not already full
- Compare the value of the (rear) pointer with the maximum size of the array
- If equal then (rear) pointer becomes zero
- Otherwise, add one to the (rear) pointer
- Insert new item in position indicated by (rear) pointer
2
Q
removing an item from a circular queue
A
- Check the queue is (not already) empty
- Compare the value of the front pointer with the maximum size of the array
- If equal then front pointer becomes one
- Otherwise, add one to the front pointer