Photo AI

Last Updated Sep 27, 2025

Arrays Simplified Revision Notes

Revision notes with simplified explanations to understand Arrays quickly and effectively.

user avatar
user avatar
user avatar
user avatar
user avatar

242+ students studying

Arrays

Overview

An array is a data structure that stores a collection of elements, typically of the same data type, in a contiguous block of memory. Arrays are used to efficiently store and access multiple values using a single variable name and an index. You need to know arrays up to 3 dimensions, as they are commonly used for organising data.

What is an Array?

  • Definition: An array is a collection of elements, all of the same data type, identified by an index or set of indices.
  • Indexing:
    • Arrays are zero-indexed in many programming languages (e.g., Python, Java, C++), meaning the first element is accessed with index 0.
    • Example: In an array arr = [10, 20, 30], arr[0] refers to 10.
  • Fixed Size: Arrays are typically of a fixed size, meaning the number of elements is determined when the array is created.

Types of Arrays

One-Dimensional Array

A single row of elements.

lightbulbExample

Example: A list of student grades.

grades = [85, 90, 78, 92]

Two-Dimensional Array

Consists of rows and columns, like a table or grid.

lightbulbExample

Example: A matrix representing a chessboard.

chessboard = [
    [1, 0, 0, 1],  # Row 1
    [0, 1, 1, 0],  # Row 2
    [1, 1, 0, 0],  # Row 3
    [0, 0, 1, 1]   # Row 4
]

Three-Dimensional Array

Represents data in three dimensions, such as multiple layers of 2D grids.

lightbulbExample

Example: A 3D array for storing temperature values over time for different locations.

temperature = [
    [[15, 16], [20, 21]],  # Day 1: Locations 1, 2
    [[18, 19], [22, 23]]   # Day 2: Locations 1, 2
]

Uses of Arrays

  • Storing Data: Arrays are used to store collections of related data, such as lists of names, scores, or positions in a game.
  • Organising Complex Data: Multi-dimensional arrays help organise more complex data, such as images (2D arrays) or 3D models (3D arrays).
  • Efficiency: Arrays allow for fast access to elements using their index.

Recognising When to Use Arrays

  • When you have a collection of similar data: For example, storing a list of test scores.
  • When you need to perform operations on a group of values: For example, summing all elements.
  • When data needs to be structured in rows and columns: For example, storing a table of student marks or pixel data for images.
  • When managing multiple datasets: For example, storing daily temperatures across multiple locations.

Examples

lightbulbExample

Example 1: One-Dimensional Array Store and print the names of 3 students.


students = ["Alice", "Bob", "Charlie"]
print(students[1])  # Output: Bob

lightbulbExample

Example 2: Two-Dimensional Array Store and access a table of marks for 3 students in 2 subjects.


marks = [
    [85, 90],  # Student 1: Subject 1, Subject 2
    [78, 88],  # Student 2: Subject 1, Subject 2
    [92, 95]   # Student 3: Subject 1, Subject 2
]

print(marks[2][1])  # Output: 95 (Student 3, Subject 2)

lightbulbExample

Example 3: Three-Dimensional Array Store and access daily temperature data for 2 cities over 2 days.


temperature = [
    [[15, 16], [18, 19]],  # Day 1: City 1, City 2
    [[20, 21], [22, 23]]   # Day 2: City 1, City 2
]

print(temperature[1][0][1])  # Output: 21 (Day 2, City 1, second time point)

Note Summary

infoNote

Common Mistakes

  • Index Out of Bounds: Trying to access an index that doesn't exist in the array (e.g., arr[5] when arr only has 3 elements).
  • Incorrect Dimensional Indexing: Forgetting the correct number of indices for multi-dimensional arrays.

Example: Using arr[1] instead of arr[1][2] for a 2D array.

  • Confusion Between Arrays and Lists: Some languages like Python use flexible lists, but in many languages (like Java), arrays are fixed in size.

:::

infoNote

Key Takeaways

  • Arrays are data structures that store multiple elements of the same type.
  • They can be one-dimensional (like a list), two-dimensional (like a grid), or three-dimensional (like multiple layers of grids).
  • Arrays are widely used for storing and efficiently accessing structured data.
  • A proper understanding of indexing and dimensions is essential for effectively using arrays in programs.
Books

Only available for registered users.

Sign up now to view the full note, or log in if you already have an account!

500K+ Students Use These Powerful Tools to Master Arrays

Enhance your understanding with flashcards, quizzes, and exams—designed to help you grasp key concepts, reinforce learning, and master any topic with confidence!

90 flashcards

Flashcards on Arrays

Revise key concepts with interactive flashcards.

Try Computer Science Flashcards

9 quizzes

Quizzes on Arrays

Test your knowledge with fun and engaging quizzes.

Try Computer Science Quizzes

29 questions

Exam questions on Arrays

Boost your confidence with real exam questions.

Try Computer Science Questions

27 exams created

Exam Builder on Arrays

Create custom exams across topics for better practice!

Try Computer Science exam builder

12 papers

Past Papers on Arrays

Practice past papers to reinforce exam experience.

Try Computer Science Past Papers

Other Revision Notes related to Arrays you should explore

Discover More Revision Notes Related to Arrays to Deepen Your Understanding and Improve Your Mastery

96%

114 rated

Data Structures

Records, Lists & Tuples

user avatar
user avatar
user avatar
user avatar
user avatar

256+ studying

191KViews

96%

114 rated

Data Structures

Linked Lists

user avatar
user avatar
user avatar
user avatar
user avatar

358+ studying

189KViews

96%

114 rated

Data Structures

Stacks

user avatar
user avatar
user avatar
user avatar
user avatar

248+ studying

180KViews

96%

114 rated

Data Structures

Queues

user avatar
user avatar
user avatar
user avatar
user avatar

230+ studying

188KViews
Load more notes

Join 500,000+ A-Level students using SimpleStudy...

Join Thousands of A-Level Students Using SimpleStudy to Learn Smarter, Stay Organized, and Boost Their Grades with Confidence!

97% of Students

Report Improved Results

98% of Students

Recommend to friends

500,000+

Students Supported

50 Million+

Questions answered