Data Structures & Sub-Programs (Edexcel GCSE Computer Science)

Revision Note

Robert Hampton

Expertise

Computer Science Content Creator

Data Structures

What is a data structure?

  • A data structure provides a structured way to store data, which makes it easy to access and manipulate

  • Examples of data structures are:

    • Arrays

    • Records

Arrays

  • An array is a sequence of data, of the same data type stored under the same identifier

  • Elements stored in an array can be identified by an index (position in the array)

  • Indexes start with the value 0

  • An array can be both 1-dimensional and 2-dimensional

Records

  • A record is a sequence of data, usually of mixed data types with a fixed length

  • Elements stored in an array can be identified by an index (position in the array)

  • Indexes start with the value 0

Structure

Example

Arrays

scores = [1, 4, 2, 6, 2]

Records

Students = [001,"Bob", 2.99, "Birmingham"]

  • scores[0] holds the value 1

  • scores[2] holds the value 2

  • students[3] holds the value "Birmingham"

Exam Tip

Python has it's own data structure called a 'list' which can look like both an array and record BUT they are not the same thing!

In the exam, if a list holds data of all the same type then it can be thought of as an array, if data is different types it can be thought of as a record

Python example

# Create an array of numbers

numbers = [5, 11, 15, 20, 25]

# Access elements by index

first_number = numbers[0] # Accesses the first element (index 0)

last_number = numbers[-1] # Accesses the last element (using negative index)

# Print the entire array

print("Array:", numbers)

# Modify an element

numbers[2] = 12 # Change the third element (index 2) to 12

# Print the modified array

print("Modified array:", numbers)

# Loop through the array

for number in numbers:

print("Number:", number)

1-dimensional & 2-dimensional arrays

Python example

# 1-dimensional array (list of numbers)

numbers = [3, 7, 11, 15]

# Access elements by index

first_number = numbers[0]

print("First element (1D array):", first_number)

# Loop through the array

for number in numbers:

print("Number (1D array):", number)

# 2-dimensional array

temperature_data = [

[20, 25, 30], # Week 1 temperatures

[22, 27, 29], # Week 2 temperatures

]

# Access elements by row and column index

week1_monday_temp = temperature_data[0][0] # Week 1, Monday temperature

print("Week 1, Monday temperature (2D array):", week1_monday_temp)

# Print the entire 2D array

for row in temperature_data:

print(row) # Prints each row as a list

# Loop through the 2D array (accessing elements)

for week in temperature_data:

for day in week:

print("Temperature:", day)

You've read 0 of your 0 free revision notes

Get unlimited access

to absolutely everything:

  • Downloadable PDFs
  • Unlimited Revision Notes
  • Topic Questions
  • Past Papers
  • Model Answers
  • Videos (Maths and Science)

Join the 100,000+ Students that ❤️ Save My Exams

the (exam) results speak for themselves:

Did this page help you?

Robert Hampton

Author: Robert Hampton

Rob has over 16 years' experience teaching Computer Science and ICT at KS3 & GCSE levels. Rob has demonstrated strong leadership as Head of Department since 2012 and previously supported teacher development as a Specialist Leader of Education, empowering departments to excel in Computer Science. Beyond his tech expertise, Robert embraces the virtual world as an avid gamer, conquering digital battlefields when he's not coding.