Unit 01

Arrays & Strings

The simplest way to hold many values: a fixed block of memory where every item sits at a known distance from the start. Almost every other structure either builds on this or exists to work around its limits.

index value 0 1 2 3 4 4 9 2 7 1 arr[2] → 2, found instantly — no searching needed

// elements sit contiguously in memory, so any index is a direct lookup

What it is

An array stores a fixed-size, ordered collection of elements in one continuous block of memory. Because every element is the same size, the computer can calculate exactly where any element sits just from its index, without having to look at anything else first. A string is, under the hood, usually just an array of characters.

Why it's useful

Where it struggles

Time complexity

OperationTime
Access by indexO(1)
Search (unsorted)O(n)
Insert / delete at endO(1)
Insert / delete in middleO(n)

Quick check

← All topics Next: Linked Lists →