Introduction to Data Structures

intermediate25 min

Learning objectives

  • Define a data structure
  • Explain why different data structures exist
  • Distinguish between linear and non-linear structures
  • Justify the selection of an appropriate data structure for different computing problems

Learn

AQA 4.2.1 — Data structures

Retrieval: Sequence 3 finished by contrasting good and poor ways to organise a single program's variables. This sequence asks the same "organise it well" question about collections of related data.

A data structure is a way of organising and storing multiple related values so they can be accessed and modified efficiently. Different problems need different structures — there's no single "best" one, which is precisely why AQA's specification (and this whole sequence) covers several.

Linear vs non-linear

  • Linear: elements are arranged in a sequence, one after another — arrays, records, queues, stacks (this sequence).
  • Non-linear: elements can branch or connect in more complex ways — graphs, trees, hash tables (Sequence 12, Year 13).

Static vs dynamic

  • Static: a fixed size, set when created (AQA's theoretical array model).
  • Dynamic: can grow or shrink while the program runs (a Python list, in practice).

This is a knowing-vs-choosing lesson

Every lesson later in this sequence teaches you to implement a specific structure. This lesson is different: it's about choosing between structures you may not have met yet, based on what a problem actually needs — a skill you'll keep using for the rest of the course, and one AQA examines separately from "can you write the code."

Worked example — the same data, three different structures

Imagine storing five students' exam scores.

# A single variable per student - doesn't scale, painful to process as a group
aisha_score = 82
tom_score = 67

# An array/list - simple, ordered, good if you only need the values
scores = [82, 67, 91, 74, 88]

# A dictionary - good if you need to look a score up BY student name
scores_by_name = {"Aisha": 82, "Tom": 67, "Priya": 91, "Liam": 74, "Sofia": 88}

All three store the same underlying information. The right choice depends entirely on how the data will actually be used: do you need every score in order (a list is enough), or do you need to instantly find one particular student's score by name (a dictionary is far better)?

Common mistake

Choosing a structure because it's the most recently learned or most "advanced" one, rather than because it fits the problem. A simple list is often the correct choice — complexity for its own sake makes code harder to write and maintain, not better.

Data Structure Selection Exercise

For each scenario below, decide which structure fits best and justify your choice in a sentence — the justification matters as much as the answer:

  1. A print queue that must process documents in the order they were sent.
  2. A phone contacts list looked up by name, not position.
  3. A simple list of this week's five lunch menu choices, always shown in the same order.
  4. The most recently visited pages in a web browser, so "back" always returns the newest one.

Challenge

Research one real-world system (a booking system, a music streaming app, a hospital patient database — your choice) and identify which data structure(s) it most likely uses internally for at least one specific piece of functionality, with a brief justification.

Looking ahead: the next lesson (Arrays) is the first concrete structure of the course — everything from here on builds on the "choose deliberately" habit this lesson introduces.

Test yourself

Check your understanding with exam-style questions.

Go to Exam Practice
Log in to track this lesson on your progress dashboard.
Log in