Cambridge International AS & A Level Computer Science 9618
An interactive deep-dive into linear and circular queues — from abstract data types to array implementations.
Theory, diagrams, and interactive simulator for linear queues implemented in a 1D array.
MOD wrap-around, trace tool, and interactive simulator for circular queues.
10 Cambridge-style written questions with AI-powered feedback on accuracy, terminology, and depth.
An Abstract Data Type (ADT) is a collection of data together with a set of operations that can be performed on that data. The ADT defines what operations are available, but not how they are implemented.
Think of an ADT like a vending machine: you know what buttons to press (operations) and what you get out (results), but you don't need to know the internal mechanics.
An ordered collection of elements
The Queue ADT separates interface from implementation.
Documents printed in the order sent to the printer.
Callers served in the order they joined the line.
Keystrokes processed in the order typed.
HTTP requests handled first-come, first-served.
| Situation | Why a Queue? | Why Not a Stack? |
|---|---|---|
| Processing tasks in arrival order | FIFO preserves fairness | LIFO would process newest first |
| Buffering data between processes | Maintains original sequence | Would reverse the sequence |
| Breadth-first graph traversal | Explores level by level | Would give depth-first traversal |
Java implementations of linear and circular queues using 1D arrays.
public class LinearQueue {
private String[] queue;
private int front, rear, maxSize;
public LinearQueue(int size) {
maxSize = size;
queue = new String[maxSize];
front = 0; rear = -1;
}
public void enqueue(String item) {
if (rear >= maxSize - 1) {
System.out.println("Queue is full");
} else {
rear++;
queue[rear] = item;
}
}
public String dequeue() {
if (front > rear) {
System.out.println("Queue is empty");
return "";
}
String item = queue[front];
front++;
return item;
}
public boolean isEmpty() { return front > rear; }
public boolean isFull() { return rear >= maxSize - 1; }
}
Click on each line to reveal what it does.
rear = (rear + 1) % maxSize;queue[rear] = item;size = size + 1;String item = queue[front];front = (front + 1) % maxSize;if (size >= maxSize)Drag the lines of code into the correct order to build working queue operations.
Test your understanding. Receive adaptive feedback on every question.
Cambridge 9618-style written questions. Type your answer and receive targeted feedback on accuracy, terminology, and depth of understanding.