Data structure diagrams
Arrays, linked lists, queues, stacks, sets, maps, trees and graphs.
What it explains and when it is useful
Data structure diagrams show how data is organised in memory while the program runs, and which operations you use on it. Draw the structures that matter to your algorithms, with real example data.
When to use it: Whenever an algorithm in Criterion C or D depends on a data structure: a queue for fairness, a 2D array for a grid, a graph for connections, a dictionary for fast lookup.
Worked example
Illustrative: PracticePal is a fictional project used throughout this guide.
Each example uses PracticePal data. Where PracticePal itself does not need a structure, the example is labelled as an alternative.
One-dimensional array
Scroll sideways to see the whole diagram.
Two-dimensional array
Scroll sideways to see the whole diagram.
Linked list
Alternative. PracticePal keeps bookings in the database; a linked list would suit an in-memory list that changes often in the middle.
Scroll sideways to see the whole diagram.
Queue (FIFO)
Scroll sideways to see the whole diagram.
Stack (LIFO)
Alternative. An undo feature for the head of music's block editor.
Scroll sideways to see the whole diagram.
Set
Scroll sideways to see the whole diagram.
Dictionary / map
Scroll sideways to see the whole diagram.
Tree (binary search tree)
Alternative. PracticePal uses an indexed database column instead; a BST is the in-memory equivalent for fast ordered search.
Scroll sideways to see the whole diagram.
Graph
Scroll sideways to see the whole diagram.
Notation and legend
| Symbol or part | Meaning |
|---|---|
| Array cells with indexes | Fixed positions, direct access by index |
| Box-and-pointer nodes | Linked list: data + next pointer; slash = null |
| front / rear | Queue ends: dequeue at the front, enqueue at the rear |
| top | Stack: push and pop at the top only |
| Circles | Sets (Venn) or graph vertices |
| key → value | Dictionary entries |
| Shading | The element an operation is about |
Design decisions it communicates
A diagram earns marks when you explain the decisions it shows. In PracticePal's documentation these would each be one sentence:
- A queue, not a list sorted by name, because fairness means first come, first served.
- A dictionary of sets for neighbours, because membership tests are fast and the data is naturally “room → rooms”.
- A 2D array for the grid because the view is literally days × slots and is filled cell by cell.
Common mistakes
- Drawing a structure your code does not use.
- No example data, so the diagram explains nothing.
- Not saying which operations you use (enqueue, push, lookup) and why that structure suits them.
Checklist for your own version
Ticks are saved in this browser only, so you can use the list while you draft.