GCSE Revision Aid: This resource is designed to support your revision and may contain errors. If you find a discrepancy with your class teaching, your teacher is correct — please let us know at gcserevise@scott.scottrix.co.uk.

CS10: Data Structures

Foundation Higher AQAEdexcelOCREduqasCCEA

Understanding 1D arrays, 2D arrays, and records - how to declare, access, iterate, and use them in practical programs.

Fastmail

📋 What are Data Structures?

Data structures are ways of organising and storing data so it can be accessed and modified efficiently. At GCSE, you need to know about arrays (1D and 2D) and records.
Data Structure Description When to Use
1D Array A list of items of the same type, accessed by index Storing a list of scores, names, or temperatures
2D Array A grid of items in rows and columns, accessed by two indices Storing a seating plan, grid, or spreadsheet
Record A collection of named fields of different types Storing related data about one entity (e.g. a student)

📊 1D Arrays

A 1D array is an indexed collection of items of the same data type stored under one name. Each item is called an element and is accessed using its index (position number). Arrays are zero-indexed in most languages - the first element is at index 0.

Declaring and Initialising

Array Declaration
scores ← [85, 92, 78, 90, 67]     // Array of 5 integers
names ← ["Ali", "Beth", "Carla"]  // Array of 3 strings

Accessing Elements

Accessing by Index
scores ← [85, 92, 78, 90, 67]
OUTPUT scores[0]     // 85 (first element)
OUTPUT scores[2]     // 78 (third element)
OUTPUT scores[4]     // 67 (fifth/last element)
Array Indexing:
Index 0 = First element
Index 1 = Second element
Index n-1 = Last element (where n is the array length)

For array of length 5, valid indices are 0, 1, 2, 3, 4

Modifying Elements

Changing Array Values
scores ← [85, 92, 78, 90, 67]
scores[2] ← 88    // Change third element from 78 to 88
OUTPUT scores[2]     // Now outputs 88

Iterating Through Arrays

Using a FOR Loop
scores ← [85, 92, 78, 90, 67]
FOR i ← 0 TO 4
    OUTPUT scores[i]
NEXT i
// Outputs: 85, 92, 78, 90, 67
Finding the Total
scores ← [85, 92, 78, 90, 67]
total ← 0
FOR i ← 0 TO 4
    total ← total + scores[i]
NEXT i
OUTPUT "Total: ", total        // 412
OUTPUT "Average: ", total / 5  // 82.4
Finding the Maximum
scores ← [85, 92, 78, 90, 67]
maxScore ← scores[0]
FOR i ← 1 TO 4
    IF scores[i] > maxScore THEN
        maxScore ← scores[i]
    ENDIF
NEXT i
OUTPUT "Highest: ", maxScore   // 92

🔲 2D Arrays

A 2D array is an array of arrays - a grid with rows and columns. Each element is accessed using two indices: the row index and the column index. Think of it like a table or spreadsheet.

Declaring a 2D Array

2D Array Declaration
grid ← [[1, 2, 3],
           [4, 5, 6],
           [7, 8, 9]]

This creates a 3x3 grid (3 rows, 3 columns).

Accessing Elements

2D Array Access
grid ← [[1, 2, 3],
           [4, 5, 6],
           [7, 8, 9]]
OUTPUT grid[0][0]    // 1 (row 0, column 0)
OUTPUT grid[1][2]    // 6 (row 1, column 2)
OUTPUT grid[2][1]    // 8 (row 2, column 1)
2D Array Indexing:
grid[row][column]
First index = row number (starts at 0)
Second index = column number (starts at 0)

Iterating Through 2D Arrays

Nested FOR Loop
grid ← [[1, 2, 3],
           [4, 5, 6],
           [7, 8, 9]]
FOR row ← 0 TO 2
    FOR col ← 0 TO 2
        OUTPUT grid[row][col]
    NEXT col
NEXT row
// Outputs all 9 numbers in order
Practical Example: Seating Plan
seats ← [["Empty", "Bob", "Empty"],
             ["Alice", "Empty", "Carl"],
             ["Empty", "Dana", "Empty"]]
OUTPUT seats[1][0]   // "Alice" (row 1, seat 0)
seats[0][0] ← "Eve"   // Assign Eve to row 0, seat 0

📄 Records

A record is a data structure that groups related fields of different data types under one name. Each field has a name and can hold a different type of data. Records are ideal for representing real-world entities.

Defining a Record

Record Definition
TYPE Student
    name AS STRING
    age AS INTEGER
    tutorGroup AS STRING
    averageGrade AS REAL
ENDTYPE

Creating and Using Records

Record Instance
student1 ← NEW Student()
student1.name ← "Alice"
student1.age ← 16
student1.tutorGroup ← "10B"
student1.averageGrade ← 7.5

OUTPUT student1.name          // "Alice"
OUTPUT student1.averageGrade  // 7.5
Array of Records
TYPE Student
    name AS STRING
    score AS INTEGER
ENDTYPE

class ← [NEW Student(), NEW Student(), NEW Student()]
class[0].name ← "Alice"
class[0].score ← 85
class[1].name ← "Bob"
class[1].score ← 72
class[2].name ← "Carla"
class[2].score ← 91

FOR i ← 0 TO 2
    OUTPUT class[i].name, ": ", class[i].score
NEXT i
Feature Array Record
Access method By index number By field name
Data types All elements same type Each field can be different type
When to use List of similar items Related data about one thing
Example List of scores [85, 92, 78] Student {name, age, grade}

⚠️ Common Mistakes

Mistake Why It's Wrong How to Fix It
Accessing index 5 in a 5-element array Indices go from 0 to 4 for length 5 Use LENGTH(array) - 1 for the last index
Confusing row and column in 2D arrays grid[0][1] and grid[1][0] are different Remember: grid[row][column]
Forgetting to initialise array elements Uninitialised elements may have unknown values Set all elements before reading them
Using wrong data type in arrays Arrays hold one type only Use records if you need different types

❓ Practice Questions

Q1: Write pseudo-code to declare an array of 5 temperatures and output the third temperature.

Q2: Write pseudo-code that finds the sum of all elements in the array [10, 20, 30, 40, 50].

Q3: A 2D array represents a 3x3 tic-tac-toe board. How would you access the centre square?

Q4: Define a record called Car with fields for make (string), model (string), year (integer), and price (real).

Q5: Write pseudo-code that iterates through an array of names and outputs only the names that start with "A".

✅ Answers

  1. temps ← [18.5, 20.3, 22.1, 19.8, 21.0]
    OUTPUT temps[2]    // Outputs 22.1 (third element, index 2)
  2. numbers ← [10, 20, 30, 40, 50]
    total ← 0
    FOR i ← 0 TO 4
        total ← total + numbers[i]
    NEXT i
    OUTPUT total    // 150
  3. The centre square is at row 1, column 1: board[1][1]
  4. TYPE Car
        make AS STRING
        model AS STRING
        year AS INTEGER
        price AS REAL
    ENDTYPE
  5. names ← ["Alice", "Bob", "Amy", "Charlie", "Anna"]
    FOR i ← 0 TO 4
        IF SUBSTRING(names[i], 0, 1) = "A" THEN
            OUTPUT names[i]
        ENDIF
    NEXT i

🎯 Exam Tips

⚠️ Common Errors

✗ Thinking arrays and records are the same thing ✓ An array stores multiple values of the SAME data type accessed by index; a record stores related values of DIFFERENT data types accessed by field name.

✗ Confusing 0-based and 1-based indexing ✓ Most programming languages use 0-based indexing (first element is index 0). Some pseudo-code uses 1-based. Always check the exam board convention.

✗ Forgetting that arrays have a fixed size once declared ✓ In most GCSE-level languages, arrays have a fixed size declared at creation. You cannot add or remove elements beyond the declared size.

✗ Believing a 2D array is a completely different concept from a 1D array ✓ A 2D array is an array of arrays — each row is itself a 1D array. Access uses two indices: array[row][column].

✍️ Model Answer

Full-Mark Response

A program needs to store the names and test scores of 5 students. Explain why a record is more suitable than two separate arrays, and write pseudo-code to declare and use this data structure. [5 marks]

Using two separate arrays (one for names, one for scores) keeps related data in separate structures, making it harder to keep data together when sorting or passing to subroutines. A record groups related fields of different types into one unit. TYPE Student name : STRING score : INTEGER ENDTYPE declare students : ARRAY[1:5] OF Student students[1].name ← 'Alice' students[1].score ← 87 students[2].name ← 'Bob' students[2].score ← 72 This keeps each student's name and score together as a single unit, making the data easier to manage, sort, and pass to subroutines.

📊 AO Deep Dive

Assessment Objective Analysis

AO1 (Computational Thinking — 40%): Demonstrate knowledge and understanding of the principles and concepts of computer science, including data structures: arrays and records for AQA 8525, OCR J277 & Edexcel 1CP2.

AO2 (Application — 40%): Apply knowledge and understanding of computer science, including data structures: arrays and records to analyse problems in computational terms and to design, write and evaluate solutions.

AO3 (Evaluation — 20%): Evaluate the effectiveness, correctness and efficiency of computational solutions, including data structures: arrays and records, and make reasoned judgements about trade-offs.

📝 Exam Technique

GCSE Computer Science Exam Tips:
Arrays: same type, accessed by index. Records: different types, accessed by field name. Always state the size when declaring an array. For 2D arrays, use two indices [row][column]. Know the difference between arrays (same type, indexed) and records (different types, named fields). When asked to choose, consider whether the data is the same type (array) or mixed types (record).

📝 Exam Questions by Topic

🎬 Video Resources

Share this page

Ready to ace your GCSE Computer Science exams?

Get the best revision books and guides to boost your grades.