← Arrays & Strings · guided lesson

Arrays & Strings

1 / 18 · story

the story

Array (contiguous memory)

Every tool here exists because something was too slow or broke without it. Here is what.

1957 · John Backus and the IBM FORTRAN team

Early programmers kept tables in numbered memory words and worked out every address by hand. FORTRAN, built at IBM from 1954 and described in 1957, made the array part of the language: DIMENSION A(1000) declares 1000 slots, and A(I) reads one. The compiler turns the subscript into an address, so programmers never do that arithmetic again. C, Java and almost every language since kept the same idea: a numbered row of equal-sized slots.

the problem it solved

Keeping many values of one kind under one name and reaching any of them by its number, without hand-written address arithmetic.

why it matters: without it

No O(1) access by position: every lookup would walk node by node, and everything built on arrays — hash tables, heaps, ArrayList — would lose its speed.

sources: Backus et al. — The FORTRAN Automatic Coding System (Western Joint Computer Conference, 1957) ↗ · Full text at the Computer History Museum's Software Preservation Group ↗

also in this chapter: Dynamic array (ArrayList) · Immutable String & StringBuilder · Counting array (int[26]) · Kadane's algorithm · Prefix & suffix passes · Boyer–Moore majority vote · Next lexicographic permutation · Index as home (cyclic placement, sign markers)