z-algo-core

Installation
SKILL.md

Algorithm core

Pick the data structure by what the code does with it — membership check, ordering, top-k, adjacency — not by habit, then measure before reaching for anything fancier.

Complexity quick table

Structure Lookup Insert Ordered iteration Use for
Array/slice O(n) O(1) amortized append O(n log n) sort default choice, best cache locality
Hash map O(1) average O(1) average none membership, dedup, counting
Balanced tree O(log n) O(log n) O(n) in order only when ordered iteration/range queries are load-bearing
Heap O(1) peek O(log n) none top-k, priority scheduling
Graph (adjacency list) — — BFS/DFS O(V+E) dependency graphs, reachability

When it matters

  • for small bounded inputs, begin with the simplest correct structure; there is no portable size threshold where a scan beats hashing
  • measure representative key types, hit rates, mutation patterns, and repeated queries before optimizing; profile the actual hot path
  • an algorithm swap that isn't on a measured hot path is speculative work; [[z-no-over-engineering]] applies to data structures too
Installs
11
First Seen
Aug 29, 2026