Revision Notes
OxfordAQA A-Level Computer Science (9645): Queues – Revision Notes
Recall notes for OxfordAQA 9645 sub-topic 3.2.3 Queues: FIFO, pointer conventions, empty and full tests, circular wrap, library methods and a self-test.
- Subject
- Computer Science
- Level
- AS LEVEL
- Topic
- Topic 2 – Fundamental data structures
- Author
- Marlbridge Academic Team
- Updated
- Reviewed by
- Harris Khan (what this means)
Aligned to OxfordAQA A Level Computer Science (9645), 2024-onwards. Official specification .
Syllabus page (what it covers and how it is assessed): OxfordAQA A Level Computer Science.
Syllabus points this page covers
9645 (AS Level)
- 3.2.3 Queues
Found an error? Report a correction.
Need help with this topic? Request a free trial class for A Level Computer Science (9645).
These notes condense sub-topic 3.2.3 Queues of OxfordAQA International AS and A-level Computer Science (9645), Version 1.1 (AS content in topic 3.2 Fundamental data structures). For explanations, code and full traces, see the queues study guide; then practise with the queues practice questions.
What the specification requires
- A queue is a first-in first-out (FIFO) structure.
- Apply enqueue (add) and dequeue (remove).
- Describe situations where a queue is appropriate.
- Implement a linear and a circular queue in a one-dimensional array.
- Test whether an array queue is empty or full.
- Use a library implementation of a queue.
Key terms
| Term | Meaning |
|---|---|
| FIFO | The first item added is the first removed |
| Front | The end items are removed from |
| Rear | The end items are added at |
| Enqueue | Add an item at the rear |
| Dequeue | Remove and return the item at the front |
| Linear queue | Array queue whose pointers never wrap round |
| Circular queue | Array queue whose pointers wrap to index 0 using MOD |
| Buffer | Temporary store that holds data in arrival order until it can be processed |
| Overflow / underflow | Enqueue on a full queue / dequeue on an empty queue |
Array implementations compared
| Version | Empty test | Full test | Weakness |
|---|---|---|---|
| Linear, moving front (front = 0, rear = −1) | rear < front | rear = size − 1 | Space at the start is wasted after dequeues |
| Linear, shuffling (front fixed at 0, rear = −1) | rear = −1 | rear = size − 1 | Each dequeue moves every remaining item |
| Circular with count | count = 0 | count = size | Needs an extra variable |
| Circular, one slot spare (front = rear = 0, rear = next free) | front = rear | (rear + 1) MOD size = front | Holds only size − 1 items |
Always use the convention the question gives. Read the starting values of the pointers before tracing.
Circular pointer arithmetic
pointer ← (pointer + 1) MOD size
Size 5: 3 → 4 → 0 → 1. Without MOD, the pointer runs off the end of the array.
Logical contents of a circular queue: start at front, move forward with wrap, stop before rear (or after
count items). Values left in the array outside that range are not in the queue.
Worked reminder: a count-based trace
Size 3, front = 0, rear = −1, count = 0. Enqueue X, Y, Z; dequeue; enqueue W.
| After | Array | front | rear | count |
|---|---|---|---|---|
| enqueue X, Y, Z | X, Y, Z | 0 | 2 | 3 (full) |
| dequeue (returns X) | X, Y, Z | 1 | 2 | 2 |
| enqueue W | W, Y, Z | 1 | 0 | 3 (full) |
Logical queue at the end: Y, Z, W.
When a queue fits
| Situation | Why FIFO matters |
|---|---|
| Print jobs to one printer | Jobs are served fairly in the order sent |
| Keyboard buffer | Keys must be processed in the order typed |
| Processes waiting for a processor | Each waits its turn |
| Packets waiting to be sent | Data must not be reordered |
| Checkout simulation | Models first-come, first-served |
Library methods
| Library | Add | Remove | Watch out for |
|---|---|---|---|
Python collections.deque |
append |
popleft |
IndexError when empty; maxlen discards the oldest item silently |
Python queue.Queue |
put |
get |
get waits when empty; put_nowait raises queue.Full |
C# Queue<T> |
Enqueue |
Dequeue |
InvalidOperationException when empty; Peek reads the front |
Exam traps
- Wrong end. Dequeue is always from the front.
- Check first. Test full or empty before changing a pointer.
- Linear full test in a circular queue.
rear = size − 1does not mean full once the pointers wrap. - Reading the array left to right. Read from
front, wrapping round. - Mixed conventions. Decide whether
rearis the last item or the next free slot, and stick to it. - Library
pop(). On a deque,pop()removes from the right (the rear), which breaks FIFO.
Quick self-test
- What does FIFO stand for?
- At which end does enqueue add an item?
- Give the full test for a circular queue that uses a count.
- In a size-6 circular queue,
rearis 5. Where does the next item go? - Why does a linear moving-front queue report full when it is not?
- What is the disadvantage of the shuffling linear queue?
- Why does the “one slot spare” circular queue never fill its last slot?
- Give one situation where a queue is appropriate, with a reason.
- Which
dequemethod removes from the front? - What happens if you call
Dequeue()on an empty C#Queue<T>? - A circular queue of size 4 has front = 3 and count = 2. Which indexes hold the items?
- What is a buffer?
Answers
- First in, first out.
- The rear.
- count = size.
- Index 0, because (5 + 1) MOD 6 = 0.
rearhas reached the last index even though dequeued slots at the start are free.- Every dequeue moves all remaining items, so it is slow for large queues.
- So that front = rear can only mean empty, not full.
- Print jobs: they should be printed in the order they were sent (or any valid example with reason).
popleft()- It throws an
InvalidOperationException. - Indexes 3 and 0.
- A temporary store that holds data in arrival order until it can be processed.
Official syllabus
OxfordAQA International AS and A-level Computer Science (9645) specification, Version 1.1, for International AS exams May/June 2025 onwards and International A-level exams May/June 2026 onwards: sub-topic 3.2.3 Queues.
Related resources
-
Study guides
OxfordAQA A-Level Computer Science (9645): Records
OxfordAQA 9645 sub-topic 3.2.2 in depth: designing records, Python classes and data classes, structs, arrays of records and copying versus referencing.
Computer Science · OxfordAQA · AS Level
Read guide -
Practice questions
OxfordAQA A-Level Computer Science (9645): Records – Practice Questions
Twelve original OxfordAQA 9645 questions on sub-topic 3.2.2 Records: field types, data classes, arrays of records and reference traces, with full answers.
Computer Science · OxfordAQA · AS Level
Try questions -
Revision notes
OxfordAQA A-Level Computer Science (9645): Records – Revision Notes
Recall notes for OxfordAQA 9645 sub-topic 3.2.2 Records: fields, record design, Python and struct syntax, arrays of records, traps and a self-test.
Computer Science · OxfordAQA · AS 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.