GGCSE Revision Hub

3.2.6 Data structures

AQA Computer Science 8525Topic 3.2 — ProgrammingFoundation & Higher

This is the longest topic in the specification and the one that carries most of the Paper 1 marks. It covers the statements every program is built from, the operators that do the work, the structures that hold data, and the discipline that makes code safe to rely on. Two of the specification's supported languages are Python and C#, so the examples here use Python-style syntax with the AQA pseudo-code where the specification demands it. Learn this as something you write, not something you memorise.

What you need to know

What a data structure is

Understand the concept of data structures. A data structure is a way of organising data so that it can be used efficiently. The specification notes that it may help to set the concept in various contexts students already know — the list of things on a shopping trolley, the seating plan of a theatre, the index of a book. All of those are data structures, and all of them make some operations easy and others slow.

Key fact: A data structure is a way of organising data so that it can be used efficiently.

Arrays

Use arrays (or equivalent) in the design of solutions to simple problems. Only one and two-dimensional arrays are required. An array is a fixed-size sequence of values of the same type, indexed by position, and the index runs from 0 upwards. Because the positions are fixed, an array is very fast to index — but you cannot add an item in the middle without shifting everything along.

Key fact: An array is a fixed-size, indexed sequence of values of the same type, indexed from 0.

Two-dimensional arrays

A two-dimensional array is a grid of rows and columns, and it is how you model anything tabular: a timetable, a grid of scores, a board game. You index it with two values, the row and the column. This is exactly the structure that appears in the image and sound topics in Paper 2, where pixel grids and sample data are both two-dimensional.

Key fact: A two-dimensional array is indexed by row and column.

Records

Use records (or equivalent) in the design of solutions to simple problems. A record groups together fields that all describe one thing. The specification's example is a record definition for a car, with make, model, reg, price and noOfDoors, each with its own data type. The important idea is that the fields have different types — a string and a real and an integer together.

Key fact: A record groups fields of different types that all describe one thing.

Arrays against records

The choice between them is about what the data looks like. If every item is the same kind of thing, use an array. If each item is described by several different fields, use an array of records. A class of students, each with a name, an age and a test score, is an array of records; a list of the scores alone is a simple array.

Key fact: Same kind of thing, use an array; several fields per thing, use an array of records.

Designing with them

The specification says it may be helpful to suggest or demonstrate how data structures could be used in a practical setting. So a question might give you a scenario and ask which structure you would use. Read the scenario carefully: if it needs to be searched by position, an array; if it needs to be sorted, sorted or unsorted arrays matter; if each entry has several attributes, records.

Key fact: Choose the structure from what the data has to do: index, sort, or hold several fields.

Flashcards

Exam questions

Written in the style of AQA Computer Science, with a mark scheme for each one. No question here is a real past paper question.

mcq1 mark

Which data structure would you use to store the details of 30 students, each with a name, an age and a test score?

  • A one-dimensional array of names
  • An array of records
  • A two-dimensional array of characters
  • A single record with three fields

Mark scheme: 1 mark for identifying an array of records, because every student is the same kind of thing but is described by several fields of different types.

short3 marks

Explain in English the difference between an array and a record, and give one use for each.

Mark scheme: 1 mark for stating that an array is a fixed-size sequence of values of the same type indexed by position. 1 mark for stating that a record groups several fields of different types describing one thing. 1 mark for giving a correct example of each, such as an array of test scores and a record holding a student's name, age and score.

six6 marks

Explain in English what a data structure is and how you would choose between an array and a record when designing a solution.

Mark scheme: Level 1 (1-2 marks): A short answer saying a data structure organises data for efficient use. Level 2 (3-4 marks): A structured answer covering arrays, two-dimensional arrays and records with examples. Level 3 (5-6 marks): A detailed answer explaining the concept with everyday examples, describing one- and two-dimensional arrays and the fact that indexes start at 0, describing records with the car record from the specification and the fact that fields can have different types, and explaining how the choice is driven by the shape of the data and the operations required, such as searching by position, sorting, or holding several attributes per item.

Other sections in this topic

Practise these questions

Answer them in the interactive view and they get marked against the same mark scheme, one mark at a time, with the reason for each mark.

Open the interactive topic →