TOPIC
Contiguous memory: O(1) access, but inserts/deletes shift neighbours.
WHY DID WE NEED ARRAYS?
THE WALLA program with only single variables (x, y, z…) cannot hold a THOUSAND marks or a MILLION pixels — you can't name a box per value.
THE IDEAPut values in one contiguous block and reach any of them by INDEX: address = base + i × size. One name, n values, O(1) access to any of them.
A row of numbered lockers: locker #42 is one step away, but adding a locker in the middle means shifting every locker after it.
Traverse, insert, delete and update elements.
Locate a value — scan it, or halve a sorted range.
Order the elements — compare, swap, partition, merge.
Pattern techniques that turn O(n²) brute force into O(n).
2-D arrays: traversal order, rotation, multiplication, sparsity.
Classic interview problems that turn the array techniques into solutions.