Covers asymptotic complexity, data structure selection, sorting, searching, DP, graph, greedy, string algorithms, and at-scale streaming/sketching tools. Triggered by algorithm selection, performance review, and scaling problems.
How this skill is triggered — by the user, by Claude, or both
Slash command
/pproenca-dot-skills-1:computer-science-algorithmsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
A practitioner-oriented reference for choosing and implementing classical algorithms and data structures correctly. Organized by execution-lifecycle impact: the earliest decisions (asymptotic class, data-structure choice) cascade through everything else, so the rules near the top of the table matter most.
A practitioner-oriented reference for choosing and implementing classical algorithms and data structures correctly. Organized by execution-lifecycle impact: the earliest decisions (asymptotic class, data-structure choice) cascade through everything else, so the rules near the top of the table matter most.
Scope: the patterns that show up in everyday production code review, reasonable interview / contest problems, and the at-scale toolbox (sketches, streaming, distributed primitives) — not an exhaustive cover of CLRS. Topics intentionally outside the current version: network flow, modular arithmetic, Bellman-Ford and Floyd-Warshall as standalone rules, SCC (Tarjan/Kosaraju), computational geometry, FFT, Manacher / Z-function as standalone rules. They're flagged inline in the relevant rules.
Distilled from CLRS (Introduction to Algorithms, 4th ed.), Sedgewick & Wayne (Algorithms, 4th ed., Princeton), Skiena's Algorithm Design Manual, Laaksonen's Competitive Programmer's Handbook, cp-algorithms.com, and the USACO Guide.
Use these rules when:
in-checks on lists, pop(0) on lists, string concatenation in loops, naive substring search| # | Category | Prefix | Impact | Why it cascades |
|---|---|---|---|---|
| 1 | Asymptotic Complexity & Algorithm Selection | comp- | CRITICAL | Wrong O() class makes every other optimization irrelevant |
| 2 | Data Structure Selection | ds- | CRITICAL | The container determines which operations are cheap |
| 3 | Sorting & Searching | srch- | HIGH | Foundation for greedy, two-pointer, sweep-line, binary-search-on-the-answer |
| 4 | Dynamic Programming | dp- | HIGH | Exponential → polynomial transformations |
| 5 | Graph Algorithms | graph- | HIGH | Networks, dependencies, routing, scheduling all reduce to graphs |
| 6 | Divide & Conquer / Recursion | divide- | MEDIUM-HIGH | Logarithmic-factor speedups; stack-depth and recurrence traps |
| 7 | Greedy Algorithms | greedy- | MEDIUM | Fast when correct, silently wrong when not |
| 8 | String & Sequence Algorithms | str- | MEDIUM | Pattern matching, parsing, substring queries |
| 9 | Scale & Probabilistic Algorithms | scale- | MEDIUM | Sketches, streaming, distributed primitives — situational, decisive when they apply |
comp-pick-algorithm-class-from-input-bound — Match O() to n before writing codecomp-amortize-instead-of-worst-casing — Total cost, not per-op worst casecomp-watch-for-quadratic-blowup-from-membership-in-list — Linear in checks in loops are O(n²)comp-prefer-iterative-builders-over-string-concatenation — Join / buffers, not +=comp-derive-recurrences-via-master-theorem — Write the recurrence before coding recursioncomp-treat-space-complexity-as-first-class — Memory kills services before time doesds-hash-map-for-keyed-lookup — Build the index once, then O(1) lookupsds-set-for-uniqueness-and-membership — Dedup and "have I seen this?" in O(1)ds-heap-for-top-k-and-priority-queues — O(n log k), priority-queue idiomsds-deque-for-both-end-operations — O(1) pop-front for BFS queues and sliding windowsds-balanced-bst-or-sorted-container-for-range-queries — Predecessor / successor / range scands-union-find-for-dynamic-connectivity — Near-O(1) grouping and mergingds-prefix-sums-for-repeated-range-sums — O(1) range sum after O(n) preprocessingds-fenwick-or-segment-tree-for-mutable-range-queries — O(log n) updates + queriessrch-use-builtin-sort-not-hand-rolled — Timsort / introsort beat any hand-rollsrch-binary-search-on-sorted-data — bisect, plus binary search on the answersrch-quickselect-for-k-th-element — O(n) average for k-th / mediansrch-counting-and-radix-sort-for-bounded-integer-keys — Beat O(n log n) for integer keyssrch-two-pointers-on-sorted-data — O(n) on sorted arrays, sliding windowdp-memoize-overlapping-subproblems — @cache collapses exponentialsdp-tabulate-when-recursion-depth-or-order-matters — Bottom-up + rolling arraysdp-define-state-precisely — Underspecified state = silent wrong answersdp-knapsack-pattern — 0/1 vs unbounded; loop direction is correctnessdp-bitmask-for-small-set-states — n! → 2ⁿ · poly for n ≤ ~20dp-prove-optimal-substructure-before-coding — DP requires substructure; verify before codinggraph-bfs-for-unweighted-shortest-path — O(V+E), no heap neededgraph-dijkstra-for-non-negative-weights — Lazy-deletion heap variantgraph-topological-sort-for-dependency-order — Kahn's algorithm + DAG DPgraph-represent-as-adjacency-list-not-matrix — Sparse graphs need listsgraph-detect-cycles-during-dfs — Three-colour scheme for directed graphsgraph-kruskal-or-prim-for-mst — MST with Union-Find or heapdivide-merge-sort-pattern-for-counting-inversions — Piggy-back counting onto the merge stepdivide-watch-recursion-depth-and-stack — Iterate, or raise the stackdivide-meet-in-the-middle-for-subset-problems — 2ⁿ → 2^(n/2)divide-quickselect-vs-quicksort-partitioning — Random pivots; 3-way Dutch flaggreedy-prove-exchange-argument-before-using — Greedy needs a correctness proofgreedy-sort-by-the-right-key-for-scheduling — Finish time, deadline, value/weightgreedy-interval-merge-and-sweep-line — Events + sort + linear sweepgreedy-huffman-and-priority-queue-greedies — Heap-based "pick smallest repeatedly"str-kmp-or-builtin-find-not-naive-search — Linear worst-case substring searchstr-trie-for-prefix-queries — Autocomplete in O(|query|)str-rolling-hash-for-multiple-substring-comparisons — Two independent hashes, pleasestr-suffix-array-or-automaton-for-substring-queries — Heavy-duty substring toolingThe "unusual but valuable at scale" toolbox — sketches that trade tiny accuracy loss for orders-of-magnitude memory wins, streaming primitives for inputs that don't fit in RAM, and distributed structures that survive sharding changes.
scale-bloom-filter-for-probabilistic-membership — 1 bit/element vs 8 bytes, 1% false-positive ratescale-hyperloglog-for-cardinality-estimation — Count distinct over billions in ~12 KBscale-count-min-sketch-for-frequency-estimation — Heavy hitters and frequency queries in fixed memoryscale-reservoir-sampling-for-streams — Uniform k-sample from a stream of unknown lengthscale-consistent-hashing-for-distributed-sharding — Remap k/n keys (not all keys) on node changesscale-external-merge-sort-for-out-of-memory-data — Sort 1 TB on 8 GB of RAMscale-aho-corasick-for-multi-pattern-search — Find all of m patterns in one pass over textscale-minhash-lsh-for-near-duplicate-detection — Near-duplicate pairs in O(n), not O(n²)Start with the category that matches the question:
comp- (input-bound)ds-hash-map-for-keyed-lookup or comp-watch-for-quadratic-blowup-from-membership-in-listdp-memoize-overlapping-subproblems and comp-derive-recurrences-via-master-theoremgraph-greedy-prove-exchange-argument-before-using; fall back to dp-knapsack-patternstr-scale-Code examples are in Python (most readable across audiences). The reasoning generalizes to any language — equivalent stdlib primitives are listed where they differ.
| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |
| AGENTS.md | Auto-built TOC navigation |
complexity-optimizer — Static analysis that finds the patterns these rules diagnosenpx claudepluginhub pproenca/dot-skillsEnforces algorithm-first discipline: state Big-O, data structure, and algorithm family before writing loops, queries, or recursion. Catches O(n²), N+1, and brute-force defaults.
Implements and selects optimal data structures—hash tables (chaining, Robin Hood), balanced BSTs (AVL, Red-Black), heaps, tries, skip lists, segment/Fenwick trees, Bloom filters, Union-Find—for performance constraints, custom collections, memory optimization.
Reviews code for algorithmic complexity issues: nested loops, N+1 queries, exponential recursion, and optimization suggestions across multiple languages.