Category_Data / taxonomy.md
xupy21's picture
Add files using upload-large-folder tool
e9f27a1 verified
|
Raw History Blame Contribute Delete
10.1 kB

Final Algorithm Taxonomy (7 families, 31 categories)

ID Family Category Includes
MA-01 Mathematics Math Reasoning / Formulas arithmetic, parity, invariants, inequalities and bounds, closed-form derivation, convexity and duality arguments
MA-02 Mathematics Number Theory primes/sieve, gcd/lcm, divisors, modular arithmetic/inverse, CRT, multiplicative functions, Dirichlet convolution, min_25
MA-03 Mathematics Combinatorics & Probability counting by formula, binomials, inclusion–exclusion, bijections, linearity of expectation, probability
MA-04 Mathematics Game Theory win/lose states (also when computed by DP or search), Sprague–Grundy, Nim, strategy arguments
MA-05 Mathematics Bitwise / XOR per-bit reasoning, XOR/AND/OR properties, XOR basis
MA-06 Mathematics Linear Algebra / Polynomials Gaussian elimination, linear systems, determinants, FFT/NTT, convolution, generating functions
MA-07 Mathematics Geometry vectors, cross product, convex hull, intersections, areas, computational geometry
DS-01 Data Structures Prefix Sums / Difference Arrays 1D/2D prefix sums, difference arrays
DS-02 Data Structures Hash / Set / Map hash table, library (multi)set/map and ordered containers, coordinate compression, XOR/sum hashing of sets
DS-03 Data Structures Stack / Queue / Heap monotonic stack/deque, priority queue
DS-04 Data Structures Segment Tree / Fenwick / BST segment tree (lazy propagation, custom merge, beats), sparse table, Fenwick tree, hand-written Treap/Splay, persistent structures
DS-05 Data Structures DSU / Union-Find union-find, weighted/rollback DSU, small-to-large merging of component data
DP-01 Dynamic Programming Linear / Sequence DP prefix-state DP, grid DP, LIS/LCS, interval DP, digit DP
DP-02 Dynamic Programming Knapsack / Subset / Bitmask DP 0/1 and unbounded knapsack, subset-sum, bitmask-state DP, SOS DP
DP-03 Dynamic Programming Tree / DAG DP DP on trees, rerooting, DP along the topological order of a DAG
DP-04 Dynamic Programming DP Optimization data-structure-optimized DP, monotone-queue optimization, matrix-power DP, CHT/Li Chao, D&C / Knuth optimization, slope trick, Aliens (WQS) trick, state reduction by observation
GR-01 Graph Theory Traversal / Connectivity BFS/DFS, components, topological sort, bipartiteness, cycles, functional graphs, Eulerian paths, SCC, 2-SAT, bridges / articulation points
GR-02 Graph Theory Shortest Paths / MST Dijkstra, 0-1 BFS, Bellman–Ford, Floyd, Kruskal/Prim
GR-03 Graph Theory Flow / Matching max-flow / min-cut, min-cost flow, bipartite matching, Hall's theorem, König's theorem
GR-04 Graph Theory Tree Algorithms LCA, binary lifting, Euler tour (tree flattening), HLD, centroid decomposition, small-to-large over subtrees (DSU on tree), diameter
ST-01 Strings Pattern Matching / String Hashing KMP / prefix function, Z-function, Manacher, rolling hash
ST-02 Strings Trie / Suffix Structures trie (incl. binary trie), Aho–Corasick, suffix array / automaton, palindromic tree, LCP
PA-01 Algorithmic Paradigms Greedy exchange argument, sort-then-greedy, regret greedy
PA-02 Algorithmic Paradigms Binary / Ternary Search binary search on the answer, parallel binary search, ternary / golden-section search
PA-03 Algorithmic Paradigms Two Pointers / Sliding Window / Sweep Line two pointers, sliding window, sweep line over sorted events, interval merging
PA-04 Algorithmic Paradigms Divide & Conquer / Sqrt Decomposition D&C on arrays, CDQ, offline D&C over time (segment tree on time), sqrt blocks, Mo's algorithm, sqrt thresholds (heavy/light by size or degree)
PA-05 Algorithmic Paradigms Brute Force / Search enumeration, backtracking, pruning, meet-in-the-middle, tables precomputed by offline search, randomized algorithms
AH-01 Ad-hoc & Implementation Ad-hoc / Observation / Case Work problem-specific structural observations that no other category names, case analysis
AH-02 Ad-hoc & Implementation Constructive build an array / string / graph / order that meets the conditions
AH-03 Ad-hoc & Implementation Implementation / Simulation direct simulation, heavy implementation, many edge cases to get right

Family sizes: Mathematics 7, Data Structures 5, Dynamic Programming 4, Graph Theory 4, Strings 2, Algorithmic Paradigms 5, Ad-hoc & Implementation 4.

GPTClassify/classify.py gives the model the table above and the section below word for word, so human labels and model labels follow the same rules.

Boundary rules

These rules decide between categories when a technique could fit more than one.

General

  1. Place a technique by the Includes column, not by how close a category's name sounds, and by the technique, not by the data it runs on: KMP on an integer array is ST-01.
  2. One idea, one label. A structure that only implements another listed technique the standard way belongs to that technique: the heap in Dijkstra and the DSU in Kruskal are GR-02; the segment tree or deque of an optimized DP is DP-04; the heap of a regret greedy is PA-01. Add the structure's own category only when the structure is itself nonstandard (custom merge, persistence, beats).
  3. Not labels by themselves: sorting, a set or map used as a lookup table, lower_bound on a sorted array, a prefix sum taken once, coordinate compression, arithmetic modulo a prime only because the answer is asked modulo it, 64-bit care, fast I/O, a DFS that only computes parents, depths or subtree sizes.

Observations, math and DP 4. MA-01 vs AH-01. MA-01 when the key step is a quantitative fact that is derived: a formula or closed form, an equation, an inequality or bound, parity, an invariant, convexity. AH-01 when the key step is a structural fact about the problem's own objects: which choices never matter, the form every optimal answer can be put into, what can be ignored; or a case split. Give both only when each is a separate step of the solution. 5. DP-04 vs AH-01 / MA-01. An observation that shrinks the state or the transitions of a DP that would otherwise be too slow is DP-04 ("state reduction by observation"). An observation that removes the need for DP is AH-01 or MA-01. 6. DP-04 and the base DP. Give the base DP category (DP-01 to DP-03) as well when formulating the DP is itself a main step. 7. Counting with a DP is the DP's category. MA-03 when a count or an expectation comes from a formula, a bijection, inclusion–exclusion or linearity of expectation. 8. Win/lose states computed by DP or search are MA-04; add a DP category only when that DP is substantial on its own, such as a tree DP over positions.

Data structures 9. Library std::set/map and other ordered containers are DS-02. DS-04 is for segment trees, Fenwick trees, sparse tables, and hand-written BSTs (treap, splay) that carry augmented data. 10. Hashing a set or multiset (random weights, XOR/sum) is DS-02; hashing strings is ST-01; other randomization (random sampling, shuffling, probabilistic checks) is PA-05. 11. A monotonic stack or deque is DS-03, including sliding-window minimum. PA-03 when moving the ends of a window, or the pointers, is the idea. 12. Small-to-large merging over the subtrees of a tree (DSU on tree) is GR-04. Small-to-large merging of the data attached to DSU components is DS-05. 13. Offline processing over time (a segment tree on time with a rollback DSU, CDQ) is PA-04; the structure inside it (DS-05, DS-04) is labelled on its own.

Graphs and trees 14. On a tree, plain DFS/BFS is GR-01 and usually incidental; GR-04 needs one of its listed techniques; a DP whose state is a subtree is DP-03. 15. Topological sort or cycle detection alone is GR-01; a DP computed along the topological order is DP-03. 16. "Euler tour" in GR-04 is flattening a tree into an array. An Eulerian path or circuit through all edges is GR-01. 17. "Heavy/light" in PA-04 is splitting items by a square-root threshold on size or degree. Heavy-light decomposition of a tree is GR-04. 18. GR-03 includes matching theory used only in the argument, such as Hall's or König's theorem, even when the code runs no flow or matching algorithm. 19. When the solution builds a graph (states, residues, layered copies), label the algorithm run on it. The modelling is part of that label, not AH-01.

Math 20. Fast exponentiation of a transition matrix (a DP, a linear recurrence, walks in a graph) is DP-04. MA-06 is for other linear algebra and for polynomials. 21. An XOR basis is MA-05, not MA-06. A bitmask used as a DP state is DP-02, not MA-05. A binary trie is ST-02; add MA-05 only when per-bit reasoning is a separate step. 22. MA-07 needs real geometric computation on shapes in the plane or in space: vectors, angles, areas of polygons or other figures, intersections. Not MA-07: integrating a function (area under a curve or a piecewise-linear density), which is MA-01; rotating, reflecting or translating grid cells, which counts toward the method that uses it; axis-parallel rectangles that reduce to 1-D intervals.

Paradigms and ad hoc 23. PA-01 needs a greedy choice that makes the solution correct, usually backed by an exchange argument. Sorting before processing is not greedy by itself. 24. PA-02 is binary or ternary search over an answer or a parameter. A lower_bound on a sorted array is not PA-02. 25. PA-05 when exhaustive enumeration or search is the main engine, or when the key is that the search space is small enough, including a table precomputed offline by search. Not for a loop over a few cases inside another method. 26. AH-02 when the output is an object to build (an order, array, graph or string) and building it is a main step. A numeric answer is never AH-02. 27. AH-03 only when implementation or simulation is itself a main difficulty. Long code alone is not AH-03. Case analysis in the reasoning is AH-01; many cases to code correctly is AH-03. 28. Every interactive problem gets AH-04.