Static arrays

Watch a fixed block of memory: insert and delete by shifting the elements after the gap. The capacity never grows.

Data structures Beginner Contiguous · Fixed size ~8 min
The idea

One contiguous block, fixed capacity

A static array stores values side by side in one block of memory. The capacity is chosen when the array is created and cannot change.

Only the first length slots hold live values. To insert in the middle, every element after that index shifts right to make a gap. To delete, every element after the gap shifts left to close it.

TipIf length == capacity, insert fails — there is no free slot and the block cannot grow.
IdeaShift to insert
static_insert.pyPython
capacity = 6
# make room at index i
for j in range(length, i, -1):
    arr[j] = arr[j - 1]
arr[i] = value
length += 1

In languages like C, a fixed array looks like int arr[6].

Interactive

Run the simulation

Dashed slots are unused capacity. Watch values slide when you insert or delete.

Step 0 / 0
demo.pyPython
Array blockdemo
Ready
Shortcuts: Space play/pause · → step · ← back · R reset
Try it yourself

Insert and delete by index

Capacity stays at 6. Insert shifts right; delete shifts left. Full blocks refuse new values.

Ready
Array length 4 / capacity 6. Choose an index and press Insert or Delete.
Remember

Static array mental model

Fixed block · shift to open or close a gap · no grow.

Capacity

Chosen once

The block size is fixed. Unused slots stay empty until length grows into them.

Shift

Insert and delete

Middle inserts copy every later element one step right. Deletes copy them left.

Limit

No reallocation

When length hits capacity, insert fails. A dynamic array grows instead.