AlgoViz

Static arrays

easy 15 min

A static array is a fixed-size block of same-type slots stored side by side in memory.

Where it shows up

The same pattern appears across everyday software.

  • Images and pixel buffers

    An image is a long array of pixels stored row after row, each pixel a fixed group of bytes such as red, green and blue. Filters and GPUs find pixel (r, c) with one address calculation.

  • Audio, video and network buffers

    Sound cards, video decoders and network stacks fill a fixed-size buffer, hand it off in one go, and reuse it. No allocation in the hot path means predictable timing.

  • Lookup tables

    Precomputed sine tables, CRC tables, Fibonacci caches and character-count arrays turn repeated work into a single O(1) index.

  • Matrices in science and machine learning

    NumPy arrays, BLAS libraries and tensors in ML frameworks are contiguous typed arrays, which is what lets them use SIMD instructions and caches so well.

  • Embedded sensor arrays

    A device with a fixed number of sensors keeps one slot per sensor. Firmware often cannot allocate memory at run time, so fixed-size arrays are the norm.

  • Dynamic programming tables

    DP solutions store the answer to each subproblem at its index, for example dp[i] for the first i items, so each answer is computed once and read in O(1).