/algorithms-deep-dive:algo-foundations-and-machine-modelfrom algorithms-deep-dive
Helps choose algorithms and data structures, and explains why measured performance may differ from Big-O analysis. Covers memory hierarchy, cache lines, branch prediction, allocation, pointer indirection, and SIMD.
Ships in algorithms-deep-dive. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Part 1 of 5 of the Algorithms Deep Dive reference (plugin
algorithms-deep-dive), covering §0–§2. Sibling skills:algo-data-structures(§3–§6),algo-core-algorithms(§7–§11),algo-probabilistic-concurrency-and-measurement(§12–§14),algo-reference(§15–§20). Section numbers are shared across the set; a reference written as §N →skillpoints into that sibling skill.Currency: Verified August 2026. See §17 →
algo-referencefor the currency snapshot and what goes stale first.
How to read this. Reference, not a course, and deliberately complementary to a theory-of-computation reference: that answers "is this solvable and how hard is it"; this answers "which structure, which algorithm, and why is it slower than the analysis said."
Three markers:
- [DURABLE] — established algorithms, structures, and engineering practice. Most of this document.
- [VERSIONED] — library implementations, hardware behaviour, recent results.
- [CONTESTED] — genuine disagreement.
⚠️ GOTCHA boxes mark the places where the textbook answer and the production answer diverge.
The three framings that organize everything below:
- Data structure choice is algorithm choice. Most "algorithm problems" in real systems are solved by picking the right structure and letting the algorithm fall out. If your algorithm is complicated, your data layout is probably wrong (§3–§7 →
algo-data-structures,algo-core-algorithms).- Asymptotic analysis models the wrong machine. It assumes uniform-cost memory access, which stopped being true in the 1990s. A cache miss is ~100× an arithmetic op, and a branch mispredict ~15–20 cycles — so an O(n) scan over an array routinely beats an O(log n) walk over a pointer structure (§2). Asymptotics tell you how something scales; they do not tell you which is faster at your n.
- You will almost never write these. You will choose them. The valuable skill is knowing what your standard library actually does, what its failure modes are, and when its default is wrong for your data — not reimplementing quicksort (§13 →
algo-probabilistic-concurrency-and-measurement).
| Asked about... | Go to |
|---|---|
| How to choose — the decision method | §1 |
| Why my O(log n) is slower than your O(n) | §2 |
| Arrays, lists, and the layout question | §3 → algo-data-structures |
| Hash tables | §4 → algo-data-structures |
| Trees, B-trees, LSM trees | §5 → algo-data-structures |
| Heaps and priority queues | §6 → algo-data-structures |
| Sorting | §7 → algo-core-algorithms |
| Searching, indexing, and range queries | §8 → algo-core-algorithms |
| Graphs | §9 → algo-core-algorithms |
| Strings and text | §10 → algo-core-algorithms |
| Dynamic programming and greedy | §11 → algo-core-algorithms |
| Probabilistic and streaming structures | §12 → algo-probabilistic-concurrency-and-measurement |
| Vector / similarity search | §13.4 → algo-probabilistic-concurrency-and-measurement |
| Concurrency and lock-free structures | §14 → algo-probabilistic-concurrency-and-measurement |
| Measurement and benchmarking discipline | §13 → algo-probabilistic-concurrency-and-measurement |
| "Don't do this" | §15 → algo-reference |
| "Which is better?" | §16 → algo-reference |
| "Is this still current?" | §17 → algo-reference |
| Books and resources | §18 → algo-reference |
[DURABLE] The questions that determine the answer, in order:
algo-core-algorithms).algo-data-structures vs. §5 → algo-data-structures).algo-probabilistic-concurrency-and-measurement).algo-probabilistic-concurrency-and-measurement).algo-core-algorithms).[DURABLE] The default answer is usually "an array or a hash map." Reach for something exotic only when profiling shows you need it, and be aware that most exotic structures lose to a flat array below a few thousand elements because of §2.
[DURABLE] This section explains most of the gap between predicted and measured performance, and it is the single highest-value part of this document.
register <1 ns ~0 cycles
L1 cache ~1 ns ~4 cycles 32–64 KB
L2 cache ~4 ns ~12 cycles 256 KB – 2 MB
L3 cache ~15 ns ~40 cycles 8–64 MB, shared
DRAM ~80 ns ~200–300 cycles ⚠️ THE CLIFF
NVMe SSD ~50 µs ~100,000 cycles
network ~1 ms+
[DURABLE] The consequences that should change your defaults:
algo-probabilistic-concurrency-and-measurement).~15–20 cycles for a mispredict. Predictable branches are nearly free; unpredictable
ones are catastrophic. This is why branchless techniques exist: conditional moves,
arithmetic masking, and the branchless partitioning that makes modern quicksort fast (§7 → algo-core-algorithms).
⚠️ It's also why sorted input can make code faster — the famous "why is processing a sorted array faster" effect is entirely branch prediction, and it's a useful sanity check on whether you understand your own profile.
Allocation is expensive and often the real cost in a structure that looks algorithmically fine. Pre-allocate, pool, reuse, and prefer structures that allocate in blocks over ones that allocate per element. In GC languages, allocation is future GC pressure, and a GC pause is a latency spike attributed to the wrong place.
Pointer indirection costs a potential cache miss each hop. Every level of a pointer structure is a chance to stall.
SIMD processes 4–16 elements per instruction. Autovectorization is real but fragile; the structures that vectorize are flat, contiguous, and branch-light. This is a data layout question before it's an instruction-selection question.
[DURABLE] The synthesis: the constant factor is not a footnote in this domain — it routinely spans two orders of magnitude, and it is determined mostly by memory layout.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub the-vibey-project/vibey --plugin algorithms-deep-dive5 skills in this plugin
/algo-core-algorithmsUse when implementing or choosing a core algorithm: sorting as libraries actually implement it (introsort, Timsort, pdqsort, radix) and how to choose, searching and indexing, graph algorithms (traversal, shortest paths, topological sort, flow, union-find), string and text algorithms (substring search, edit distance, suffix structures), and dynamic programming, greedy, divide and conquer, and amortized analysis./algo-data-structuresUse when picking or debugging a concrete data structure: arrays and sequences and their memory layout, hash tables (collision resolution, open addressing and modern probing, load factor, iteration order, hash flooding, the 2025 theory result), trees and ordered structures (balanced in-memory trees, B-trees and the B-tree/LSM storage divide, tries and specialized trees), and heaps and priority queues./algo-probabilistic-concurrency-and-measurementUse when working with approximate or concurrent structures, or when measuring performance: Bloom filters, HyperLogLog, count-min sketch and streaming structures, benchmarking and profiling discipline, vector and similarity search (HNSW, IVF, approximate nearest neighbour recall), and concurrent data structures — locks, lock-free and wait-free designs, memory ordering, and the ABA problem.