Illustrated · 1 min

An array is a data structure with a fixed length. Each element of the data structure has an index, which is how we access them. For an array AA we denote A[i]A[i] as the element at index ii, where 0≤i<length(A)0\le i<\text{length}(A).

We can create a new array in O(n)O(n) and access array elements in O(1)O(1). One practical downside to arrays is that they use a lot of memory: suppose you make an array of size 10001000 to keep track of some things in your program, but end up only storing 1010 elements in it; that other empty memory cannot be touched by anything else.

Type a concept, like “slope” or “photosynthesis”.

↑ ↓ to choose · Enter to openSearch explanations and problems