An array stores values in a sequence and lets the algorithm access a value by its position. In Python algorithm practice, list is the usual array-like structure.

Arrays are often the first structure used for sorting, searching, dynamic programming, prefix sums, and two-pointer techniques.

Core Idea

The key feature of an array is indexed access. If values is a Python list, values[i] reads the element at index i.

This makes arrays good when the algorithm needs to move through positions, compare neighbors, or store one answer per index.

Python Example

values = [10, 20, 30, 40]
 
first = values[0]
last = values[-1]
values[2] = 35

The list keeps the elements in order. Access by index is constant time.

Common Confusions

Python list is dynamic. It can grow and shrink, unlike a fixed-size array in lower-level languages. For most algorithm problems, it still plays the role of an array.

Another common mistake is confusing index and value. The index is the position. The value is what is stored at that position.

When To Use It

Use an array-like list when order matters, when positions matter, or when the algorithm needs efficient access to i, i - 1, or i + 1.