Data structures
How programs organize data: arrays, lists, hash tables, trees, heaps and graphs, each with a diagram, Big-O costs and a TypeScript implementation.
Linear
Values in a sequence: by position, by link, or by order of arrival.
Values stored side by side in one block of memory that grows by doubling: O(1) access by index and amortized O(1) appends.
A chain of nodes where each holds a value and a pointer to the next: O(1) inserts and removals at known positions, O(n) to find anything.
A queue adds at the back and removes from the front, first in, first out; a deque does both at either end. All in O(1).
A fixed-size array whose read and write positions wrap around the end, giving an O(1) queue with no allocation: ideal for streams, logs and recent history.
A last-in, first-out collection: push onto the top, pop from the top, both O(1). Behind function calls, undo, parsing and depth-first search.
Hashing
Find things by key in constant time, on average.
A compact bit array that answers "definitely not present" or "probably present" using several hash functions: tiny memory, no false negatives.
Store key–value pairs in an array of buckets chosen by a hash of the key, so lookups, inserts and deletes take constant time on average.
A fixed-size cache that evicts the least recently used item, built from a hash table plus a doubly linked list so every operation is O(1).
Trees
Hierarchies that keep data ordered or prioritized.
Binary search trees that rebalance themselves with rotations, guaranteeing O(log n) search, insert and delete whatever order keys arrive in.
A complete binary tree stored in an array where every parent is smaller than its children, giving the minimum in O(1) and inserts and removals in O(log n).
A binary tree where every left subtree holds smaller keys and every right subtree larger ones: O(log n) search, insert and ordered traversal when balanced.
A tree of characters where each path from the root spells a key, so prefix searches like autocomplete take time proportional to the prefix, not the dataset.
Graphs
Things and the connections between them.
A set of vertices connected by edges, stored as an adjacency list or matrix: the structure behind maps, networks, dependencies and recommendations.
Track which items belong to the same group as groups merge: near-constant-time union and find with path compression and union by rank.