12 / 19

What is an Array? How is it stored in memory?

Array and Memory Representation

javascript
  1. 1

    Array indexing is normally zero-based, so the first element is at index 0.

  2. 2

    Contiguous storage provides excellent cache locality.

  3. 3

    For a one-dimensional array, element access is O(1).

  4. 4

    The array size is fixed in languages such as Java for native arrays; dynamic arrays provide resizable behavior.

Difficulty: 1/10

Follow-up Questions

  • Why is array access O(1)?
  • What are the trade-offs of contiguous memory allocation?
  • How does a dynamic array differ from a normal array?