
Harvard University · Jelani Nelson · 1:28:19 · Watch on YouTube
Type: university lecture (educational).
Summary
The opening lecture of Harvard's CS224 covers course logistics, then immediately attacks the belief that sorting cannot beat n log n — showing that bound only holds in the comparison model, which real machines don't obey. The lecture introduces the word-RAM model (integers in [0, 2^w), all C-style bit and arithmetic operations in O(1), w ≥ log n) and uses it to study the static predecessor problem, since a fast dynamic predecessor structure immediately yields a fast sorting algorithm. It then builds van Emde Boas trees in full (recursive √u clusters plus a summary, min-as-buffer, O(log log u) query and insert), shrinks their Θ(u) space to Θ(n) with a hash table and a charging argument, and sketches the alternative X-fast / Y-fast trie route to the same bound.
Topics
- Course logistics and goals — grading, scribing, P-sets, and how CS224 differs from CS124.
- The predecessor problem, and why it beats the n log n sorting bound — definition, baselines, and the reduction from sorting.
- The word-RAM model — universe size, word size, and the constant-time operation set.
- The landscape: bounds, combination, and sorting consequences — vEB vs. fusion trees,
√(log n), and known sorting results. - van Emde Boas trees: structure, query, insert — the recursive design and its
O(log log u)analysis. - From
Θ(u)space toΘ(n): hashing and the dictionary problem — the charging argument and the dictionary black box. - X-fast tries — bit array, OR-tree, monotone-path binary search, hashed levels.
- Y-fast tries: fixing X-fast tries by indirection — super items, balanced BSTs, amortized splits, and the matching lower bound.
graph TD
A["Sorting can't beat n log n?<br/>only in the comparison model"] --> B["word-RAM model<br/>bit tricks are O(1)"]
B --> C["Static / dynamic<br/>predecessor problem"]
C --> D["van Emde Boas tree<br/>O(log w) query & update<br/>Θ(u) space"]
D --> E["Hash table for<br/>non-empty clusters<br/>⇒ Θ(n) space"]
C --> F["Bit array + OR-tree"]
F --> G["X-fast trie<br/>O(log log u) query<br/>Θ(n·w) space, w update"]
G --> H["Y-fast trie (indirection)<br/>Θ(n) space, O(log log u)"]
C --> I["Fusion trees<br/>O(log_w n) — next lecture"]
E --> J["min(log w, log_w n) ≤ √(log n)<br/>and this is optimal"]
H --> J
I --> J
Key takeaways
- The
Ω(n log n)sorting bound is an artifact of the comparison model; in the word-RAM model, where XOR, shifts, and integer arithmetic areO(1), both predecessor and sorting go faster9:47,16:31,17:08. - van Emde Boas trees achieve
O(log w) = O(log log u)for both query and update — beating theO(log n)of balanced BSTs — via√urecursion plus a summary structure, with the minimum kept in a separate buffer so insertion never recurses deeply twice20:23,49:13,51:58,52:30. - The naive vEB layout costs
Θ(u)space (unusable atu = 2^64), but replacing the cluster array with a hash table keyed on non-empty cluster IDs cuts it toΘ(n)— proved by charging each(ID, pointer)pair to the minimum element of that cluster, which is charged exactly once55:20,57:51,59:44,1:00:39. - Choosing the better of vEB (
log w) and fusion trees (log_w n) givesmin(log w, log_w n), which is always at most√(log n), and dynamic fusion trees therefore sort inO(n √(log n))— with better results known:O(n log log n)deterministic (Han & Stock 2002) andO(n √(log log n))expected (Han & Thorup, FOCS 2002); linear-time sorting in this model is still open23:58,24:23,25:01,26:18,27:03. - X-fast tries reach
O(log log u)query by binary-searching the monotone leaf-to-root path of an OR-tree (withk-th ancestors reachable inO(1)through a heap array layout and a bit shift), but payΘ(n·w)space andwupdate time; Y-fast tries remove both factors ofwby indirection — an X-fast trie overn/wrepresentative "super items", each a balanced BST ofΘ(w)elements, split only on overflow1:13:56,1:15:41,1:21:39,1:23:08,1:26:42. - These bounds are provably optimal: a matching lower bound shows no linear- or nearly-linear-space predecessor structure can beat the min of van Emde Boas and fusion trees
1:27:49.