Revision Notes
AQA A-Level Computer Science (7517): Queues – Revision Notes
Condensed AQA 7517 section 4.2.2 recall: linear, circular and priority queue operations, empty and full tests, pointer rules, exam traps and a self-test.
- Subject
- Computer Science
- Level
- A LEVELS
- Topic
- Fundamentals of data structures
- Author
- Marlbridge Academic Team
- Updated
- Reviewed by
- Harris Khan (what this means)
Aligned to AQA A Level Computer Science (7517), 2015-onwards. Official specification .
Syllabus page (what it covers and how it is assessed): AQA A Level Computer Science.
Syllabus points this page covers
7517
- 4.2.2 Queues
Found an error? Report a correction.
Need help with this topic? Request a free trial class for A Level Computer Science (7517).
Condensed recall for 4.2.2 Queues, AQA A-Level Computer Science (7517): add an item, remove an item, test for empty and test for full, for linear, circular and priority queues. Full algorithms and side-by-side traces are in the queues study guide; exam-style questions are in the queues practice questions.
The queue rule
FIFO: first in, first out. Add at the rear, remove from the front. Uses: print queues, keyboard buffers, processes waiting for the processor.
Array representation
q[0 … maxSize-1] the items
front index of the next item to remove
rear index of the item added most recently
size number of items held
creation: front ← 0 rear ← -1 size ← 0
State your own starting values in an answer, and keep every operation consistent with them.
The twelve operations at a glance
| Add | Remove | Empty test | Full test | |
|---|---|---|---|---|
| Linear | Full test; rear ← rear + 1; store; size + 1 | Empty test; read q[front]; front ← front + 1; size − 1 | size = 0 | rear = maxSize − 1 |
| Circular | Full test; rear ← (rear + 1) MOD maxSize; store; size + 1 | Empty test; read q[front]; front ← (front + 1) MOD maxSize; size − 1 | size = 0 | size = maxSize |
| Priority (kept in order) | Full test; shift lower-priority items back; insert behind equal priorities; size + 1 | Empty test; take the front item | size = 0 | size = maxSize |
Linear queue facts
- Pointers only move forward.
- Can report full while slots at the front are free.
- Shuffling remaining items forward after each removal fixes this, but every removal then takes time proportional to the queue length.
Circular queue facts
- The array is treated as a ring; pointers wrap with MOD maxSize.
- Freed slots are reused; no items are moved.
- Pointers alone cannot tell full from empty: use a size counter or leave one slot unused.
Wrap check: maxSize 5, rear = 4. Add: rear ← (4 + 1) MOD 5 = 0.
Trace check: circular queue of 4 slots; add A, B, C; remove twice (A, then B); add K, L, M. Now front = 2, rear = 1, size = 4, and the queue holds C, K, L, M. A further add is rejected. The same operations on a linear queue fail at L, with only two items held.
Priority queue facts
- Highest priority removed first; equal priorities leave in arrival order.
- Method 1: keep items ordered on adding (insert with a strict
<comparison so a new item goes behind equal priorities). Fast removal, slower adding. - Method 2: add at the rear; on removal, scan for the first item with the highest priority. Fast adding, slower removal.
Example: add (print, 2), (save, 5), (email, 2), (backup, 5) → front first: save 5, backup 5, print 2, email 2.
What DeQueue does not do
It does not erase the slot. It moves front and reduces size; the old value stays until overwritten but lies outside the queue.
Key terms
| Term | Definition |
|---|---|
| Queue | FIFO abstract data type: add at the rear, remove from the front |
| Front pointer | Index of the next item to be removed |
| Rear pointer | Index of the most recently added item |
| Linear queue | Queue whose pointers only move forward through the array |
| Circular queue | Queue whose pointers wrap from the last index to the first, reusing slots |
| Priority queue | Queue where the highest-priority item is removed first, equal priorities in arrival order |
| Overflow | Attempting to add to a full queue |
| Underflow | Attempting to remove from an empty queue |
Exam traps
- No MOD in a circular queue: the pointer runs off the end.
- Wrong full test for a linear queue: it is
rear = maxSize - 1, notsize = maxSize, unless items are shuffled. - Order inside EnQueue: with rear starting at −1, move the pointer first, then store.
- Order inside DeQueue: read
q[front]before moving front. - Equal priorities: arrival order must be kept.
- Empty and full tests must come before remove and add.
Self-test
- What does FIFO stand for?
- Give the creation values of front, rear and size used above.
- Write the line that advances rear in a circular queue.
- Give the full test for a circular queue with a size counter.
- Why can a linear queue report full when it is not?
- What is the cost of fixing that by shuffling?
- Why are pointers alone not enough to tell full from empty in a circular queue?
- In a circular queue of 6 slots, front = 4 and size = 3. Which indices are occupied?
- In a priority queue, what decides the order of two items with the same priority?
- In method 1, why is the comparison
<rather than≤? - What happens to the value in a slot when its item is removed?
- Name one use of a queue.
Answers
- First in, first out.
- front = 0, rear = −1, size = 0.
rear ← (rear + 1) MOD maxSize.- size = maxSize.
- Its rear pointer has reached the last index; slots freed at the front cannot be reused.
- Every removal moves all remaining items, so removal time grows with the length of the queue.
- In both states
(rear + 1) MOD maxSize = front. - 4, 5 and 0.
- Arrival order: the earlier item leaves first.
- So a new item stops behind items of equal priority that arrived earlier.
- It stays in the array until overwritten, but it is no longer part of the queue.
- Any one: print queue; keyboard buffer; processes waiting for the processor.
More resources on this topic
Related resources
-
Study guides
AQA A-Level Computer Science (7517): Single- and Multi-Dimensional Arrays
Deeper guide to AQA 7517 section 4.2.1.2: designing solutions with 1-D, 2-D and n-dimensional arrays, with traced algorithms for vectors and matrices.
Computer Science · AQA · A Level
Read guide -
Practice questions
AQA A-Level Computer Science (7517): Single- and Multi-Dimensional Arrays – Practice Questions
Original AQA 7517 section 4.2.1.2 questions with full answers: array traces, writing 1-D and 2-D algorithms, matrices, tuples and 3-D array sizing.
Computer Science · AQA · A Level
Try questions -
Revision notes
AQA A-Level Computer Science (7517): Single- and Multi-Dimensional Arrays – Revision Notes
Condensed AQA 7517 section 4.2.1.2 recall: vectors, matrices, tuples, the standard array algorithms, nested-loop rules, exam traps and a self-test.
Computer Science · AQA · A Level
Revise topic
Get free revision emails (optional)
Occasional emails with practice questions, worked explanations and links to free resources for the qualification and subjects you choose. No spam, and you can unsubscribe from any email. The free tools on this site never need an email.