Arithmetic sequences
easy 13 minAn arithmetic sequence adds the same difference d at every step, like stairs of equal height.
Where it shows up
The same pattern appears across everyday software.
Array indexing in memory
A contiguous array of 8-byte values starting at address 1000 stores its elements at 1000, 1008, 1016, ... The CPU finds element i with base + i × size, which is the nth-term formula and the reason array access is O(1).
Pagination and offsets
An API returning 20 results per page starts page p at offset (p - 1) × 20. The page starts form an arithmetic sequence 0, 20, 40, ... and any page is computed directly, without walking the earlier ones.
Linear retry backoff
A client that waits 1, 2, 3, ... seconds between retries has waited k(k + 1)/2 seconds in total after k retries. Teams use that sum to pick a retry limit that fits inside a request timeout.
Counting pairwise work
Comparing every pair of n records for duplicates, or connecting every pair of n services, takes n(n - 1)/2 operations. At 10,000 records that is about 50 million comparisons, which is why deduplication uses sorting or hashing instead.
Bubble and selection sort
Each pass of these sorts looks at one fewer element than the last, so the comparisons are (n - 1) + (n - 2) + ... + 1 = n(n - 1)/2. That arithmetic sum is exactly why both sorts are O(n²).