Kramizo
Log inSign up free
HomeWJEC GCSE Computer ScienceProgramming: Data Structures
WJEC · GCSE · Computer Science · Revision Notes

Programming: Data Structures

1,742 words · Last updated July 2026

Ready to practise? Test yourself on Programming: Data Structures with instantly-marked questions.
Practice now →
Quick answer

Data structures organise information efficiently in programs. Arrays store multiple values of the same type, accessed by index positions starting at 0. Two-dimensional arrays create grid structures requiring two indices. Records group related data of different types with named fields. Arrays of records combine both structures for database-like functionality. File handling enables persistent storage through opening, reading/writing, and closing operations. Select structures based on data relationships, types, and whether information needs preserving after program termination. Always close files and validate array indices to avoid errors.

What you'll learn

Data structures are the foundation of programming, enabling you to organise and store data efficiently. This revision guide covers the essential data structures required for WJEC GCSE Computer Science, including arrays, records, and file handling techniques. You'll learn how to select appropriate structures for different programming tasks and manipulate data effectively in your code.

Key terms and definitions

Array — A data structure that stores multiple values of the same data type under a single identifier, with each element accessed using an index number.

Index — A numeric position that identifies the location of an element within an array, starting from 0 in most programming languages.

Two-dimensional array — An array organised in rows and columns, forming a grid structure where each element is accessed using two indices.

Record — A data structure that groups related data items of different data types under a single identifier, with each item called a field.

Field — An individual component within a record that stores a specific piece of information.

Sequential file access — Reading or writing data to a file in order from beginning to end, processing each item consecutively.

File handling — The process of creating, opening, reading from, writing to, and closing files to enable persistent data storage.

Persistent storage — Data that remains saved after a program terminates, typically stored in files on secondary storage devices.

Core concepts

Arrays and their uses

Arrays store collections of data items of the same data type under one variable name. Each element occupies a specific position identified by an index number.

One-dimensional arrays function like a simple list:

  • Declared with a fixed size in most programming languages
  • Index positions typically start at 0
  • Elements accessed using square bracket notation: arrayName[index]
  • Ideal for storing lists such as student names, test scores, or inventory quantities

Example declaration in Python:

scores = [78, 92, 65, 88, 71]

Example in pseudocode:

DECLARE scores[5] AS INTEGER

Key operations with one-dimensional arrays:

  • Assigning values: scores[0] = 78
  • Retrieving values: print(scores[2]) outputs 65
  • Iterating through elements using loops
  • Searching for specific values
  • Finding maximum or minimum values

Two-dimensional arrays

Two-dimensional arrays organise data in a table format with rows and columns. Each element requires two indices to locate it: one for the row and one for the column.

Common applications include:

  • Seating plans for a classroom or theatre
  • Board games like chess or noughts and crosses
  • Timetables showing periods against days
  • Spreadsheet-style data

Example declaration in Python:

seatingPlan = [
    ["Alice", "Bob", "Charlie"],
    ["David", "Emma", "Fiona"],
    ["George", "Hannah", "Ian"]
]

To access "Emma" (row 1, column 1):

student = seatingPlan[1][1]

Traversing two-dimensional arrays requires nested loops:

for row in range(3):
    for column in range(3):
        print(seatingPlan[row][column])

Records and structured data

Records allow you to group related data items of different types together. Unlike arrays, where all elements must be the same type, records can contain integers, strings, Booleans, and other data types within a single structure.

In Python, records are typically implemented using dictionaries or classes:

student = {
    "name": "Sarah Johnson",
    "age": 15,
    "yearGroup": 11,
    "averageScore": 78.5
}

Accessing fields:

print(student["name"])  # Outputs: Sarah Johnson
student["age"] = 16     # Updates the age field

Arrays of records combine both structures, storing multiple records in a single array:

students = [
    {"name": "Sarah Johnson", "age": 15, "yearGroup": 11},
    {"name": "Michael Chen", "age": 16, "yearGroup": 11},
    {"name": "Aisha Patel", "age": 15, "yearGroup": 10}
]

Accessing data from arrays of records:

print(students[1]["name"])  # Outputs: Michael Chen

This structure is particularly useful for databases, customer records, product catalogues, and employee information systems.

File handling fundamentals

File handling enables programs to save and retrieve data permanently, making data persist beyond program execution. Files are stored on secondary storage devices such as hard drives or solid-state drives.

Three essential file operations:

  1. Opening a file — Prepares the file for reading or writing
  2. Reading/Writing data — Transfers information between program and file
  3. Closing a file — Completes the operation and saves changes

Reading from text files

Sequential file access processes data from start to finish in order. Text files typically store data line by line.

Python example reading all lines:

file = open("students.txt", "r")
for line in file:
    print(line)
file.close()

Reading into an array:

scores = []
file = open("scores.txt", "r")
for line in file:
    scores.append(int(line))
file.close()

File opening modes:

  • "r" — Read mode (file must exist)
  • "w" — Write mode (creates new file or overwrites existing)
  • "a" — Append mode (adds to end of existing file)

Writing to text files

Writing data to files enables persistent storage of program results, user input, or processed information.

Writing single values:

file = open("output.txt", "w")
file.write("Total score: 450\n")
file.close()

Writing array contents:

names = ["Alice", "Bob", "Charlie"]
file = open("names.txt", "w")
for name in names:
    file.write(name + "\n")
file.close()

Important considerations:

  • Opening in write mode ("w") deletes existing file contents
  • Use append mode ("a") to add to existing files
  • Include newline characters (\n) to separate lines
  • Always close files to ensure data is saved properly

Selecting appropriate data structures

Choosing the correct data structure depends on the programming task requirements:

Use one-dimensional arrays when:

  • Storing a list of items of the same type
  • Maintaining a sequence order matters
  • Working with simple collections (scores, names, temperatures)

Use two-dimensional arrays when:

  • Data naturally fits a grid or table structure
  • Representing mathematical matrices
  • Creating game boards or seating arrangements

Use records when:

  • Grouping related information about a single entity
  • Different data types need combining
  • Creating database-style structures

Use files when:

  • Data must persist after program termination
  • Sharing data between different programs
  • Processing large datasets too big for memory
  • Creating backups of important information

Worked examples

Example 1: Array manipulation (4 marks)

Question: Write pseudocode to create an array that stores five temperatures, then calculate and display the average temperature.

Model answer:

DECLARE temperatures[5] AS REAL
DECLARE total, average AS REAL

temperatures[0] = 18.5
temperatures[1] = 20.2
temperatures[2] = 19.8
temperatures[3] = 21.1
temperatures[4] = 19.4

total = 0
FOR index = 0 TO 4
    total = total + temperatures[index]
NEXT index

average = total / 5
OUTPUT average

Mark scheme:

  • Array correctly declared (1 mark)
  • All five temperatures assigned (1 mark)
  • Loop correctly iterates through array (1 mark)
  • Average correctly calculated and output (1 mark)

Example 2: Two-dimensional array (5 marks)

Question: A school needs to store test scores for 3 students across 4 subjects. Write code to create a suitable two-dimensional array, populate it with sample data, and calculate the total score for student 2.

Model answer:

scores = [
    [67, 72, 80, 65],  # Student 1
    [85, 78, 92, 88],  # Student 2
    [70, 75, 68, 72]   # Student 3
]

student2Total = 0
for subject in range(4):
    student2Total = student2Total + scores[1][subject]

print("Student 2 total:", student2Total)

Mark scheme:

  • Two-dimensional array correctly structured (1 mark)
  • Sample data included (1 mark)
  • Correct indexing to access student 2 (row 1) (1 mark)
  • Loop correctly iterates through subjects (1 mark)
  • Total calculated and displayed correctly (1 mark)

Example 3: File handling with records (6 marks)

Question: A program stores customer records containing name and age. Write code that reads customer data from a file called "customers.txt" and displays only customers aged 18 or over.

Model answer:

file = open("customers.txt", "r")

for line in file:
    data = line.strip().split(",")
    name = data[0]
    age = int(data[1])
    
    if age >= 18:
        print(name)

file.close()

Mark scheme:

  • File opened correctly in read mode (1 mark)
  • Loop processes each line (1 mark)
  • Data correctly split into components (1 mark)
  • Age converted to integer (1 mark)
  • Conditional statement checks age correctly (1 mark)
  • File closed (1 mark)

Common mistakes and how to avoid them

  • Confusing index positions — Remember most languages start array indexing at 0, not 1. The first element is array[0], and for an array of size 5, the last element is array[4], not array[5].

  • Accessing out-of-bounds indices — Attempting to access scores[5] when an array only has 5 elements (indices 0-4) causes runtime errors. Always ensure loop conditions match array size.

  • Forgetting to close files — Files must be closed after use with file.close(). Failing to do so may result in data not being saved properly or file corruption.

  • Incorrect two-dimensional array syntax — When accessing 2D arrays, remember the row comes first: array[row][column], not the other way around.

  • Using wrong file mode — Opening a file in write mode ("w") deletes existing content. Use read mode ("r") for reading and append mode ("a") to add without deleting.

  • Not converting data types from files — Data read from text files arrives as strings. Convert to appropriate types: int(line) for integers, float(line) for decimals.

Exam technique for "Programming: Data Structures"

  • Command words matter — "State" requires a simple answer; "Describe" needs more detail; "Explain" requires reasons or justifications; "Write code" expects actual programming statements or pseudocode.

  • Show your working for code questions — Even if syntax isn't perfect, correct logic scores marks. Use comments to explain your approach if unsure about exact syntax.

  • Read data structure questions carefully — Questions often specify whether to use pseudocode or a specific language. They may also specify array size, data types, or file formats that must be followed precisely.

  • Marks typically align with statement count — A 3-mark programming question usually requires approximately 3 distinct correct statements or operations. Don't overcomplicate simple tasks.

Quick revision summary

Data structures organise information efficiently in programs. Arrays store multiple values of the same type, accessed by index positions starting at 0. Two-dimensional arrays create grid structures requiring two indices. Records group related data of different types with named fields. Arrays of records combine both structures for database-like functionality. File handling enables persistent storage through opening, reading/writing, and closing operations. Select structures based on data relationships, types, and whether information needs preserving after program termination. Always close files and validate array indices to avoid errors.

Programming: Data Structures: common questions

What do you need to know about Programming: Data Structures for WJEC GCSE Computer Science?

Data structures organise information efficiently in programs. Arrays store multiple values of the same type, accessed by index positions starting at 0. Two-dimensional arrays create grid structures requiring two indices. Records group related data of different types with named fields. Arrays of records combine both structures for database-like functionality. File handling enables persistent storage through opening, reading/writing, and closing operations. Select structures based on data relationships, types, and whether information needs preserving after program termination. Always close files and validate array indices to avoid errors.

What are the most common mistakes in Programming: Data Structures?

Confusing index positions: Remember most languages start array indexing at 0, not 1. The first element is array[0], and for an array of size 5, the last element is array[4], not array[5]. Accessing out-of-bounds indices: Attempting to access scores[5] when an array only has 5 elements (indices 0-4) causes runtime errors. Always ensure loop conditions match array size. Forgetting to close files: Files must be closed after use with file.close(). Failing to do so may result in data not being saved properly or file corruption.

Where can I practise Programming: Data Structures questions for free?

Kramizo has free WJEC GCSE Computer Science practice questions on Programming: Data Structures, each marked instantly with a full explanation. No card is required.

Free for GCSE students

Lock in Programming: Data Structures with real exam questions.

Free instantly-marked WJEC GCSE Computer Science practice — 45 questions a day, no card required.

Try a question →See practice bank