How do stacks, queues and linked lists work, and how are they implemented and used?
Dynamic data structures: stacks (LIFO) and queues (FIFO) with their push, pop, enqueue and dequeue operations and pointer management, linear and circular queues, and singly and doubly linked lists with insertion and deletion.
An Eduqas Component 1 answer on stacks, queues and linked lists: LIFO and FIFO behaviour, push, pop, enqueue and dequeue with pointer management, the wrap-around in a circular queue, and inserting and deleting nodes in a linked list.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
What this dot point is asking
Eduqas wants you to describe stacks and queues, their operations and pointer management, the wrap-around in a circular queue, and how a linked list inserts and deletes nodes by changing pointers. These are the core dynamic structures: unlike a fixed array, they model data that grows and shrinks.
The answer
Stacks (LIFO)
Queues (FIFO) and circular queues
Linked lists
Examples in context
The call stack is a stack: each function call pushes a frame and each return pops one, which is exactly why infinite recursion causes a stack overflow. A print spooler is a queue: documents print in submission order. A circular buffer (a circular queue) backs streaming audio so freed slots are reused continuously. Linked lists underpin structures that change size a lot, such as the chains in a hash table or the adjacency lists of a graph, both of which Eduqas covers in the next dot point.
Try this
Q1. State the order of removal for a stack and for a queue. [2 marks]
- Cue. Stack: last in, first out (LIFO). Queue: first in, first out (FIFO).
Q2. A circular queue of size has its rear pointer at index . After one more enqueue, what is the rear index? [1 mark]
- Cue. .
Q3. Give one advantage and one disadvantage of a linked list compared with an array. [2 marks]
- Cue. Advantage: grows and shrinks at run time with cheap insertion and deletion. Disadvantage: no direct indexing, so reaching an item needs an traversal from the head.
Exam-style practice questions
Practice questions written in the style of WJEC Eduqas exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
Eduqas 20206 marksA stack is implemented in an array with a top pointer initially set to . Describe, using pseudocode, the push and pop operations, including how an overflow and an underflow are detected.Show worked answer β
Push (up to 3 marks): check for overflow first, then increment the pointer, then store the value.
PROCEDURE push(value)
IF top = maxIndex THEN
REPORT "stack overflow"
ELSE
top <- top + 1
stack[top] <- value
ENDIF
ENDPROCEDURE
Pop (up to 3 marks): check for underflow first, then read the value, then decrement.
FUNCTION pop()
IF top = -1 THEN
REPORT "stack underflow"
ELSE
value <- stack[top]
top <- top - 1
RETURN value
ENDIF
ENDFUNCTION
Markers reward incrementing the pointer before storing on push, decrementing after reading on pop, and the overflow (top at the maximum) and underflow (top at ) checks.
Eduqas 20224 marksExplain why a circular queue is often preferred to a linear queue implemented in an array, and describe how the rear pointer wraps around.Show worked answer β
In a linear array queue, repeated enqueues and dequeues move both pointers towards the end, so the front of the array becomes unusable even when the queue is not full, wasting space (up to 2 marks).
A circular queue treats the array as a ring: when the rear pointer reaches the last index, the next enqueue sets it back to index using modulo arithmetic, , so the freed front slots are reused (up to 2 marks).
Markers reward the wasted-space problem of the linear queue and the modulo wrap-around of the circular queue. A full-or-empty distinction (using a counter or a spare slot) earns credit too.
Related dot points
- Static data structures: one- and multi-dimensional arrays, records (structs), tuples and sets, how they are stored contiguously in memory, address calculation for array elements, and choosing the appropriate structure for a task.
An Eduqas Component 1 answer on static data structures: one- and multi-dimensional arrays, records, tuples and sets, how they are stored contiguously in memory, calculating the address of an array element, and choosing the right structure for a problem.
- Trees, graphs and hash tables: binary search trees and their traversals (in-order, pre-order, post-order), graphs as adjacency matrices and adjacency lists, and hashing for direct-access tables including collision handling.
An Eduqas Component 1 answer on trees, graphs and hash tables: binary search trees and in-order, pre-order and post-order traversals, representing graphs with an adjacency matrix or adjacency list, and hashing for fast direct access with collision handling.
- Recursion and algorithmic complexity: the base case and recursive case, how recursion uses the call stack, and Big-O notation for the time and space complexity of algorithms (constant, logarithmic, linear, polynomial and exponential).
An Eduqas Component 1 answer on recursion and complexity: the base case and recursive case, how recursion uses the call stack and can cause stack overflow, and Big-O notation for measuring how an algorithm's time and space scale with input size.
- Searching and traversal algorithms: linear search and binary search with their conditions and efficiency, and the breadth-first and depth-first traversals of trees and graphs.
An Eduqas Component 1 answer on searching: how linear search and binary search work, the precondition that binary search needs sorted data, their time complexities, and how breadth-first and depth-first traversals explore trees and graphs.
- Programming principles: primitive and composite data types, variables and constants, scope and lifetime, and the three programming constructs of sequence, selection and iteration used to build structured programs.
An Eduqas Component 1 answer on programming principles: the primitive data types, variables versus constants, local versus global scope and lifetime, type conversion, and the three programming constructs sequence, selection and iteration.
Sources & how we know this
- WJEC Eduqas GCE AS/A Level Computer Science specification (from 2015) β Eduqas (2015)