You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
A data structure is an organised way of storing and managing data so that it can be accessed and modified efficiently. Choosing the right data structure is essential for writing effective programs.
An array is a collection of elements of the same data type, stored in contiguous (consecutive) memory locations. Each element is accessed using an index (a number that indicates its position).
names = ["Alice", "Bob", "Charlie", "Diana"]
| Index | 0 | 1 | 2 | 3 |
|---|---|---|---|---|
| Value | Alice | Bob | Charlie | Diana |
names[0] returns "Alice"names[2] returns "Charlie"A one-dimensional (1D) array is a single list of values:
scores = [85, 92, 78, 90]
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.